Event_Chat and how to make it work

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

zanlez
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 16, 2004 8:58 am

Event_Chat and how to make it work

Post by zanlez » Thu Sep 16, 2004 8:33 pm

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.

zanlez
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 16, 2004 8:58 am

Post by zanlez » Fri Sep 17, 2004 3:05 pm

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

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Fri Sep 17, 2004 3:32 pm

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]}

zanlez
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 16, 2004 8:58 am

Post by zanlez » Fri Sep 17, 2004 10:15 pm

Thanks allot the Find command was very helpfull. Modifying the rangers autorange script that was made.

lokiandelse
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Sep 21, 2004 9:23 pm

Post by lokiandelse » Tue Sep 21, 2004 9:25 pm

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

zanlez
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 16, 2004 8:58 am

Post by zanlez » Tue Sep 21, 2004 10:17 pm

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.

lokiandelse
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Sep 21, 2004 9:23 pm

Post by lokiandelse » Tue Sep 21, 2004 10:56 pm

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.)

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Tue Sep 21, 2004 11:08 pm

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)

lokiandelse
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Sep 21, 2004 9:23 pm

Post by lokiandelse » Tue Sep 21, 2004 11:42 pm

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

zanlez
orc pawn
orc pawn
Posts: 10
Joined: Thu Sep 16, 2004 8:58 am

Post by zanlez » Wed Sep 22, 2004 8:33 pm

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;

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Wed Sep 22, 2004 9:03 pm

The short answer is no.