I didn't think #events worked on chat commands.
I have code that does something like this though for chat commands. Changed it a bit so it should do what you want:
Code: Select all
Sub Event_Chat(string chatType,string chatSender,string chatText)
/declare n int local
/declare spellName string local
/varset n 0
:space_count_loop
/varcalc n ${n}+1
/if ( ${chatText.Arg[${Math.Calc[${n}+1]}].Length} ) /goto :space_count_loop
/if ( ${chatText.Arg[1].Equal[triggerword]} ) {
/if ( ${chatText.Arg[${Math.Calc[${n}-1]}].Equal[on]} ) {
/target ${chatText.Arg[${n}]}
/varset spellName ${chatText.Mid[${Math.Calc[${chatText.Arg[1].Length}+1]},${Math.Calc[${chatText.Length}-${chatText.Arg[1].Length}-${chatText.Arg[${n}].Length}-4]}]}
} else {
/varset spellName ${chatText.Mid[${Math.Calc[${chatText.Arg[1].Length}+1]},${Math.Calc[${chatText.Length}-${chatText.Arg[1].Length}]}]}
}
/call Cast "${spellName}"
}
/return
saying "triggerword complete healing on Happywarrior" would target Happywarrior and cast CH on him. Saying "triggerword complete healing" would just cast CH on the bot's current target
I have a loop in there to count how many words there are. n is equal to the number of words. At first i tried using string.Count[ ] but it wasn't working at the time, not sure if it does now, but the above code should work either way!