Page 1 of 1

Event_Chat and how to make it work

Posted: Thu Sep 16, 2004 8:33 pm
by zanlez
ok so i've been trying to get one of all theese ranger autoshoot programs. Without any success to brag about. So i've started looking into the coding myself. And i really can't get the sender info.

Code: Select all

Sub Event_Chat(ChatType,Sender,ChatText)
          /if (${String[@ChatText].Equal[i]})    {
          /echo ${Sender}
          }
That one doesn't work. Tried to make it as easy as i could to see if there was any progress.

Code: Select all

Sub Event_Chat(ChatType,Sender,ChatText) 
    
   /if (${ChatText.Equal[inc]}) {
   /echo ${Sender}
And if i wrote the program like this:

Code: Select all

#Chat guild

Sub Main
   /echo Test is running
:mainloop
   /doevents
   /goto :mainloop
/return

Sub Event_Chat(ChatType,Sender,"#*#i#*#")
   /echo ${Sender}
/return
It worked in the way that it echoed everyone who said anything in chat names

Doesn't work. Could someone just tell me the right way to write this code? It's bugging the crap out of me.
Appreciate it very much.

Posted: Fri Sep 17, 2004 3:05 pm
by zanlez
Been playing around alittle with it. and gotten to 2 conclusions. Gonna post the new code first.

Code: Select all

#include spellcast.inc
#Chat tell

Sub Main

/echo Test is running
:mainloop
    /doevents
    /goto :mainloop
/return

Sub Event_Chat(ChatType,Sender,ChatText)
    /if ($(ChatText.Equal[sow]})  {
    /target ${Sender}
    /tell ${Sender} inc sow
    /delay 2s
    /call Cast "Spirit of Wolf"
    }
/return
With this it sows my alt if i send a tell with only "sow" in it. How would i write the code to work if i wanted it to sow the person if "sow" was anywhere in the message. Tried putting ChatText.Equal[#*# sow #*#]
But that doesn't do it.

I've been also trying around and getting it to assist when i say inc. But the program just won't assist.

Code: Select all

Sub Event_Chat(ChatType,Sender,ChatText)
    /if ($(ChatText.Equal[inc]})  {
    /assist ${Sender}    }
/return
Help appreciated

Posted: Fri Sep 17, 2004 3:32 pm
by Cr4zyb4rd
First of all, use explicit type definitions in your subdirectory declarations..

Code: Select all

Sub Event_Chat(string ChatType,string Sender,string ChatText) 
even if it works with just the variable names, declaring a type is good practice and lets the next guy (and yourself) see what's going on easier.
How would i write the code to work if i wanted it to sow the person if "sow" was anywhere in the message. Tried putting ChatText.Equal[#*# sow #*#]
${ChatText.Find[sow]} should do the trick, very much RTFM.

Code: Select all

Sub Event_Chat(ChatType,Sender,ChatText) 
    /if ($(ChatText.Equal[inc]})  { 
    /assist ${Sender}    } 
/return 
the second ( should be {. If that's not the problem, I'm not sure what it might be...possibly out of range? If all else fails, you could do /tell mybot inc ${Target.ID} and then explicitly /target ID ${ChatText.Right[-4]}

Posted: Fri Sep 17, 2004 10:15 pm
by zanlez
Thanks allot the Find command was very helpfull. Modifying the rangers autorange script that was made.

Posted: Tue Sep 21, 2004 9:25 pm
by lokiandelse
I need some help getting this to work. I am trying to parse a channel (I.E test) for the words "need mana" but I cant seem to get it to work. What I have is:

Code: Select all

#turbo
#Chat "test"


Sub Main
   :Loop
      /doevents
   /goto :Loop
/return

Sub Event_Chat(ChatType,Sender,ChatText) 
    /if (${ChatText.Find[need mana]})  { 
    /echo ${Sender} needs mana    } 
/return 
any help would be great. thx

Posted: Tue Sep 21, 2004 10:17 pm
by zanlez
Gotten a nice assist funtion to work for group. Having trouble making it work for raids tho.

Code: Select all

#Chat raid
#Chat group

Sub Event_Chat (string ChatType, string Sender, string ChatText)
     /if (${ChatText.Find[assist}})  {
           /target ${Sender}
           /echo Assisting ${Sender}
           /assist
           /call archery
          }
/return
It works when someone sais assist in group. But when it's said in raid nothing happens. Don't even get the echo message. Tried the same code without #Chat group but it doesn't make any difference. Seems like raid isn't the right variable for the raid chat.

Posted: Tue Sep 21, 2004 10:56 pm
by lokiandelse
Well after some investegation the only options are
#chat tell (does not work if you are using tell windows)
#chat say
#chat group

it will not parse any other text (I.E. Guild, raid, channels, ect.)

Posted: Tue Sep 21, 2004 11:08 pm
by Cr4zyb4rd
what type of investigation?

looking briefly at the source...

Code: Select all

if (!stricmp(szLine,"say"))   gEventChat = gEventChat | CHAT_SAY;
            if (!stricmp(szLine,"tell"))  gEventChat = gEventChat | CHAT_TELL;
            if (!stricmp(szLine,"ooc"))   gEventChat = gEventChat | CHAT_OOC;
            if (!stricmp(szLine,"shout")) gEventChat = gEventChat | CHAT_SHOUT;
            if (!stricmp(szLine,"auc"))   gEventChat = gEventChat | CHAT_AUC;
            if (!stricmp(szLine,"guild")) gEventChat = gEventChat | CHAT_GUILD;
            if (!stricmp(szLine,"group")) gEventChat = gEventChat | CHAT_GROUP;
            if (!stricmp(szLine,"chat"))  gEventChat = gEventChat | CHAT_CHAT;
should be all the supported chat events (yes raid is conspicuously absent)

Posted: Tue Sep 21, 2004 11:42 pm
by lokiandelse
found a work around

Code: Select all

#turbo
#event NeedMana "#1#| tells test|#2#

Sub Main
   :Loop
      /doevents
   /goto :Loop
/return

Sub Event_NeedMana(Line,Sender,ChatText) 
/if (${ChatText.Find[need mana]}) {
	/echo ${Sender} needs mana
	/popup ${Sender} needs mana
	/target ${Sender}
	}
/return 
This will work even if chat is filtered in a seperate window

Posted: Wed Sep 22, 2004 8:33 pm
by zanlez
Shouldn't you just be able to add folowing line to the source and make it work?

Code: Select all

if (!stricmp(szLine,"raid")) gEventChat = gEventChat | CHAT_RAID;

Posted: Wed Sep 22, 2004 9:03 pm
by Cr4zyb4rd
The short answer is no.