Thread Tools Display Modes
12-26-20, 05:28 PM   #1
rbpaiett
A Murloc Raider
Join Date: Dec 2012
Posts: 4
Trigger PlaySound upon keyword event

I'm looking to create a macro/script/addon where if I receive a system message that any of my auction items expired or sold, I would hear a sound cue.


So basically it would search anything from CHAT_MSG_SYSTEM by keywords and triggers a PlaySound, example:

The word 'sold' appears, it activates PlaySound(5274) and ...
The word 'expired' appears, it activates PlaySound(5275).

I used to have this but lost it when I forgot to make a backup. Any advice or instruction would be very helpful.

Thanks.

Note: I'm a complete newbie with this so I don't know how to even set this up.
  Reply With Quote
12-26-20, 07:23 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Lua Code:
  1. local f = CreateFrame("Frame")     --create a frame to listen for the event
  2. f:RegisterEvent("CHAT_MSG_SYSTEM")     --register for the event you want to listen for
  3. f:SetScript("OnEvent", function(self, event, msg)     --tell WoW what to do when the event fires
  4.           if strfind(msg, "sold") then     --we only registered for one event, so we don't even have to check to see which one it was
  5.                PlaySound(5274)
  6.           elseif strfind(msg, "expired") then
  7.                PlaySound(5275)
  8.           end
  9.      end)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-26-20, 07:34 PM   #3
rbpaiett
A Murloc Raider
Join Date: Dec 2012
Posts: 4
<Bows before Seerah>

UPDATE:

Out of curiosity, what is the purpose of adding 'self' to it? You have an event that contains a message, it's not like one is listening for other players.

Last edited by rbpaiett : 12-26-20 at 09:57 PM.
  Reply With Quote
12-26-20, 10:07 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What you call variables is irrelevant. The first return from an event firing is the frame that was listening to it. The second return is the specific event that was fired in case your frame was listening for more than one. Beyond that, anything else depends on which event it was and what comes with it.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-27-20, 01:38 AM   #5
rbpaiett
A Murloc Raider
Join Date: Dec 2012
Posts: 4
Ok, very good.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trigger PlaySound upon keyword event

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off