AddTrigger not giving trigger name.

Posted by Jlzink on Wed 18 Aug 2004 04:28 AM — 7 posts, 22,215 views.

USA #0
I'm working on making a bot for an online graphical game that allows bots. Problem is that my script is suppose to add triggers upon recieving a whisper. It adds the trigger fine, but isn't adding the trigger with the name it is suppose to. The following is the script. This problem is also preventing me from using DeleteTrigger as well.

Sub Addban (thename, theoutput, thewildcards)
dim sTarget
dim sTcommand
dim tname

sTarget = Trim (thewildcards (2))
mTarget = Trim (thewildcards (2))
tname = replacer(sTarget)
sTcommand = chr(34) & "eject " & sTarget
world.addtrigger tname,"*" & mTarget & "*",sTcommand,1,6,0,"",""
world.DoCommand "Save"
end sub


Sub Removeban(thename, theoutput, thewildcards)
dim i, furre, commander
commander = Trim (thewildcards (1))
furre = Trim (thewildcards (2))
furre = replacer(furre)
world.DeleteTrigger furre

i = world.DeleteTrigger (furre)
world.note "trigger delete status was " & i

world.DoCommand "Save"
end sub

The function 'replacer()' that the the string furre is sent to, is for replacing special characters. Please help me if you can. Thanks.
USA #1
Try noting tname (world.note) so you can see if perhaps you have some invalid characters in the trigger name (or leading spaces, or whatnot).
USA #2
Didn't work. IT seems to be getting the name correctly. However only if I don't pass it to my function. However still if I use a name with no special characters as a test name it still doesn't name the trigger like it should.
USA #3
What didnt work? It doesnt note it?

And what are you trying for the test? Everyone else has no problem adding triggers. So, maybe youre overlooking some minute detail. Those tend to be the ones.
Amended on Wed 18 Aug 2004 06:42 AM by Flannel
USA #4
And what is the function returning? Since that will most likely shine some light on the problem.
Australia Forum Administrator #5
Test that sort of thing by getting the return code, eg.

world.note world.addtrigger ("test","*" & mTarget & "*",sTcommand,1,6,0,"","")

I did that, and on the second time around got code 30006.

Look that up in the help file and you will see:


eTriggerAlreadyExists (30006) Attempt to add a trigger that already exists


You can add a flag to the trigger flags:


const eReplace = 1024 ' replace existing trigger of same name

USA #6
I fixed it. I forgot to make global declaration in my script and wrote 1 line differently then I did in a prior script that did work. All is good now. Thanks for the help guys.