Heh... I did say that it wasn't tested. ;) lol
Lets try this again..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, January 04, 2003, 11:44 AM -->
<!-- MuClient version 3.32 -->
<!-- Plugin "ClanChan" generated by Plugin Wizard -->
<muclient>
<plugin
name="ClanChan"
author="kagehi"
id="47c87a3b66afba3264f8fc23"
language="VBscript"
save_state="y"
date_written="2003-01-04 11:43:32"
requires="3.32"
version="1.0"
>
</plugin>
<!-- Get our standard constants -->
<include name="constants.vbs"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
match="[CLAN]: *"
name="ClanChan"
script="ClanChan"
sequence="100"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
name="Showclan"
script="Showclan"
match="Showclan"
enabled="y"
>
</alias>
<alias
name="Clanset"
script="SetClanBuffer"
match="Clanset *"
enabled="y"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
sub ClanChan(tname, output, wilds)
'First lets get the number of lines we are keeping.
dim Keep
Keep = world.getvariable("Keep")
'Retrieve last traffic.
dim Buffer
Buffer = split(world.getvariable("ClanChan"),"^`")
'Find a blank spot, if there is one.
dim count, fnd
fnd = -1
for count = 0 to ubound(Buffer)
if Buffer(count) = "-1" or Buffer(count) = "Empty" then
fnd = count
exit for
end if
next
if fnd = -1 then
'We already have the maximum, so shift them all and add the new on into
'the last possition.
for count = 1 to ubound(Buffer)
Buffer(count - 1) = Buffer(count)
next
'Note: We use 'now' to get the time and date to time stamp it. ;)
Buffer(ubound(Buffer)) = now & " [CLAN]: " & wilds(1)
else
'This is if we found a blank.
Buffer(fnd) = now & " [CLAN]: " & wilds(1)
end if
world.setvariable "ClanChan", join(Buffer,"^`")
end sub
sub SetClanBuffer (aname, output, wilds)
'We will need a new array for later, since split does not create one you can change the size of. :p
dim Keep
Keep = wilds(1)
if isnumeric(Keep) then
if Keep < 2 then
world.note "Clan buffer cannot be less than two lines."
else
'Since arrays start at 0, we need one less than our setting or 10 lines would end up as 11.
Keep = Keep - 1
redim NewAr(Keep)
end if
'Retrieve last traffic.
dim Buffer
Buffer = split(world.getvariable("ClanChan"),"^`")
if Keep > ubound(Buffer) then
dim count
'Put existing data in the new one.
for count = 0 to ubound(Buffer)
NewAr(count) = Buffer(count)
next
'Fill the rest.
for count = ubound(Buffer) + 1 to Keep
NewAr(count) = "-1"
next
world.setvariable "ClanChan", join(NewAr,"^`")
else
if Keep = ubound(Buffer) then
world.note "New size for clan buffer is the same as last."
world.note "Command ignored."
exit sub
end if
dim count2, oldlen, strt
oldlen = ubound(Buffer)
strt = oldlen - Keep
'Store what we can.
for count2 = strt to oldlen
NewAr(count2 - strt) = Buffer(count2)
next
world.setvariable "ClanChan", join(NewAr,"^`")
end if
world.note Keep + 1 & " lines of clan messages will now be stored."
else
world.note "Must be a number! >" & Keep & "<"
end if
world.setvariable "Keep", Keep
end sub
sub ShowClan(aname, output, wilds)
dim Buffer, count
Buffer = split(world.getvariable("ClanChan"),"^`")
for count = 0 to ubound(Buffer)
if Buffer(count) <> "-1" then
world.note Buffer(count)
end if
next
end sub
sub OnPluginInstall
dim Keep
Keep = world.getvariable("Keep")
if isnumeric(Keep) and Keep > 0 then
exit sub
end if
world.setvariable "Keep", "10"
world.setvariable "ClanChan", "Empty^`-1^`-1^`-1^`-1^`-1^`-1^`-1^`-1^`-1"
end sub
]]>
</script>
</muclient>
A number of bugs I failed to note. Here is a list:
All -
Replaced ',' with '^`' to seperate lines. Lines with ',' in them would have produced nasty results otherwise. A combination of '^`' is probably never going to come up by accident in channel traffic.
ClanChan -
1. Was using 'ClanKeep' instead of 'Keep' like everyplace else. This meant it never saved more than one line at a time.
2. Discovered another bug when I fixed this and decided to use the size of the existing channel list to do things instead.
3. Changed the time stamp to be 'time [CLAN]: message'.
SetClanBuffer -
1. Was using 'dim NewAr(Keep)', only you can 'redim' arrays using a variable, but not 'dim' them. :p
2. Was trying to define the NewAr in two places. You can do this using redim, but it didn't make much sense to do it twice anyway, so moved it.
3. Couldn't figure out why the storage size of the clan list was changing, but Keep stayed at 10. Decided maybe I should have actually stored 'Keep' someplace. ;) Oops! lol
Showclan -
1. Was adding the CLAN bit before the time stamp, which looked odd imho. It wouldn't work in this spot anyway, so moved it.
OnPluginInstall -
1. Surprised this didn't generate an error.. Used isnumber, instead of isnumeric.
Anyway.. I think I got all the bugs out now and it will store and resize correctly. As to your comment about all messages showing up as being by you... Since the trigger grabs everything after the [CLAN]: part, it should also be storing the correct name. However, the fact that I used ',' to seperate things before means a line like [CLAN]: <player> says, 'yeah, Nick is uber.' would have produced two lines instead of one. Otherwise, I don't see why this would be happening. |