1. I know it can be done, but I don't know how. All other forums I have posted on have been to no avail. I'm keen to get my addon working so I can share it with my friends.

    How do I use SendAddonMessage and CHAT_MSG_Addon to play sounds? My addon makes heavy use of them, and the idea is that I use a command, a sound plays, and anyone else who has my addon will hear it as well (in party/raid of course).

    Many thanks in advance.

  2. I know it can be done, but I don't know how. All other forums I have posted on have been to no avail. I'm keen to get my addon working so I can share it with my friends.

    How do I use SendAddonMessage and CHAT_MSG_Addon to play sounds? My addon makes heavy use of them, and the idea is that I use a command, a sound plays, and anyone else who has my addon will hear it as well (in party/raid of course).

    Many thanks in advance.

  3. http://wowprogramming.com/docs/api/SendAddonMessage explains how you send a message, and http://wowprogramming.com/docs/events/CHAT_MSG_ADDON tells you how to receive said message.  What in particular don't you understand about them?  You can test this easily, since you will receive your own messages.  No need to have another person during testing.

  4. I assume this is how I'd send it? Because I seriously don't understand any of it.

    SendAddonMessage("<SOUND ID>", "PlaySoundFile("Interface\\Addons\\MyAddon\sound\\sound.wav")", [, "PARTY"])

    And this is how I'd receive it?

    this.RegisterEvent("CHAT_MSG_ADDON")

    PlaySoundFile(msg)

  5. I would like to point out that I am new to Lua, and apologies if my messages seem demanding. It's not intentional. I've been working on this for a month, and the only thing I need to do is get it to play sounds on other users machines. Example code I could use would be nice, and naturally I will credit anyone who helps!

  6. Nope, you'd want to do something like this:

    if not ReceiveSoundFrame then

       ReceiveSoundFrame = CreateFrame("Frame")

    end



    local function OnEvent(self, event, prefix, message, channel, sender)

       if prefix == "MYADDON" then

          print("Playing sound sent from: " .. sender)

          PlaySoundFile(message)

       end

    end



    local frame = ReceiveSoundFrame

    frame:RegisterEvent("CHAT_MSG_ADDON")

    frame:SetScript("OnEvent", OnEvent)



    -- Now send a message to ourselves to test it out

    local soundFile = "Sound\\Creature\\HoodWolf\\HoodWolfTransformPlayer01.wav"

    SendAddonMessage("MYADDON", soundFile, "WHISPER", UnitName("player"))

    When you send an addon message you specify a prefix (so you can tell your messages apart from another addons), the message and then what channel to send it on (and a target if you're whispering).  Whoever is receiving should be registered for CHAT_MSG_ADDON and will first check the prefix argument (to make sure that the message is for this code) then will take the message as a soundFile name, and play it.

    Let me know if that doesn't make sense.  Please note that in order for this to work the other players would need to have your addon installed, and you'd want to send to PARTY or RAID instead of WHISPER.

  7. Thank you! It works!

    I can finally finish it, once I tidy up my '/help' command. Printing all the commands to the chat frame isn't exactly the best option!