1. I've built a simple addon that looks for online/offline in the system_msg. Here is a chunk of the code:

     if (system_msg:find("online.") ~= nil) then
        UIErrorsFrame:AddMessage("|cff80FF80* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
     elseif (system_msg:find("offline.") ~= nil) then
        UIErrorsFrame:AddMessage("|cffFF8080* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
     end
    

    It works great but now I want it to look for specific people and play a sound for them. I've changed the code to the following:

    if (system_msg:find("Gankbait") ~= nil) then
        UIErrorsFrame:AddMessage("|cffFF00FF* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Creature\\Peasant\\PeasantWarcry1.wav")
    elseif (system_msg:find("online.") ~= nil) then
        UIErrorsFrame:AddMessage("|cff80FF80* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
    elseif (system_msg:find("offline.") ~= nil) then
        UIErrorsFrame:AddMessage("|cffFF8080* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
    end
    

    This works fine for what I want but I know I will have trouble when members of my guild are promoted, demoted, gquit, etc. If I try to look for "[Gankbait] has come online.", I get no result. I've searched the site and in the FrameXMLBrowser I found "|Hplayer:%s|h[%s]|h has come online."; I used WowLUA to print that in the chat frame and it looks like the online message ([%s] has come online.). Is there a way to place a player's name in that and look for it?

    Thanks in advance for any help provided.

  2. Ok, I figured out how to place a player's name in "|Hplayer:%s|h[%s]|h" but when I put "|Hplayer:Gankbait|h[%s]|h" in the code, it doesn't recognize it when Gankbait logs on.

  3. I finally got it to work. I used the following:

    if (system_msg:find("Gankbait") ~= nil and system_msg:find("online.") ~= nil) then
        UIErrorsFrame:AddMessage("|cffFF00FF* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Creature\\Peasant\\PeasantWarcry1.wav")
    elseif (system_msg:find("online.") ~= nil) then
        UIErrorsFrame:AddMessage("|cff80FF80* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
    elseif (system_msg:find("offline.") ~= nil) then
        UIErrorsFrame:AddMessage("|cffFF8080* * " .. system_msg .. " * *")
        PlaySoundFile("Sound\\Effects\\DeathImpacts\\mDeathImpactLargeWoodA.wav")
    end
    

    I have one last question and I'm sure I won't figure it out and reply to my own topic again. Is it possible to create an array of names I want to look for and put the array in place of Gankbait? Then I could add a name to the array instead of adding more elseif statements.

    My apologies for replying to myself over and over. I am sure it won't happen again. Arrays have always been one thing I have trouble grasping.

  4. No worries, hopefully other people can learn from your discussion =)

  5. Is it possible to create an array of names I want to look for and put the array in place of Gankbait? Then I could add a name to the array instead of adding more elseif statements.

  6. Sure, but then you'd need to iterate over them, i.e.

     local patterns = {}
     table.insert(patterns, "player")
     table.insert(patterns, "target")
     for idx, pattern in ipairs(patterns) do
       if string.find(blah, pattern) then
         -- do something
       end
     end