-
mike
- Posts: 7
- Joined: Wed Jan 26, 2011 3:27 pm
#1
Post
by mike » Wed Feb 02, 2011 5:50 am
Hi guys
I have the following code in the onEvent() function of a RoM addon. It plays a sound whenever someone tries to talk to me:
Code: Select all
if (event == "CHAT_MSG_WHISPER") then
PlaySoundByPath("Interface/AddOns/MsgNotify/Sounds/game.wav");
end;
if (event == "CHAT_MSG_GUILD") then
PlaySoundByPath("Interface/Addons/MsgNotify/Sounds/bell.wav");
end;
if (event == "CHAT_MSG_PARTY") then
PlaySoundByPath("Interface/Addons/MsgNotify/Sounds/bell.wav");
end;
if (event == "CHAT_MSG_SAY") then
PlaySoundByPath("Interface/AddOns/MsgNotify/Sounds/guitar.wav");
end;
The only problem is that it plays the sound whenever I post a message as well. For instance in Miller's Farm it will play the guitar.wav file everytime I cheer the chickens on.
Is there a way to check by whom the message is being posted? It might also be useful to exclude messages posted by NPCs or any users one might like to exclude for whatever reason.
All advice is appreciated in advance.
Regards
Mike
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#2
Post
by rock5 » Wed Feb 02, 2011 8:16 am
Events return more than 1 argument. In this case 1 of them should be the sender.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:
- “They say hard work never hurt anybody, but I figure, why take the chance.”
-
mike
- Posts: 7
- Joined: Wed Jan 26, 2011 3:27 pm
#3
Post
by mike » Wed Feb 02, 2011 9:53 am
Ah! arg4 works nicely! I altered my code as follows:
Code: Select all
if (event == "CHAT_MSG_WHISPER") then
PlaySoundByPath("Interface/AddOns/MsgNotify/Sounds/game.wav");
end;
if (event == "CHAT_MSG_GUILD") then
PlaySoundByPath("Interface/Addons/MsgNotify/Sounds/bell.wav");
end;
if (event == "CHAT_MSG_PARTY") then
PlaySoundByPath("Interface/Addons/MsgNotify/Sounds/bell.wav");
end;
if (event == "CHAT_MSG_SAY") then
if (arg4 ~= UnitName("player")) then
PlaySoundByPath("Interface/AddOns/MsgNotify/Sounds/guitar.wav");
end;
end;
Thanks for the advice Rock5.
Who is online
Users browsing this forum: No registered users and 3 guests