1. Does anyone see the mistake I made in this code? Trying to play sounds on crit heal, lifesaving, entering world and starting pvp. thnx

     local frame = CreateFrame("FRAME", "FooAddonFrame");
     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     frame:RegisterEvent("PLAYER_ENTERING_WORLD");
     frame:RegisterEvent("PLAYER_ENTERING_BATTLEGROUND");
    
     local guid = UnitGUID("player");
     local waar = false;
    
     local function eventHandler(self, event, ...)
         if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
             local lol = select(2, ...)
             local guidlol = select(3, ...)
             if guid == guidlol then
                 if lol == "SPELL_HEAL" then
                     local lol2 = select(15, ...)
                     if lol2 == 1 then
                         PlaySoundFile("Interface\\AddOns\\WillemSound\\megaheal.wav")
                     end
                     if waar == true then
                         PlaySoundFile("Interface\\AddOns\\WillemSound\\lifesaver.wav");
                         waar = false;
                     end
                 end
                 if lol == "SPELL_CAST_START" then
                     local leven = UnitHealth("mouseover");
                     local maxleven = UnitHealthMax("mouseover");
                     local ondervijf = ((maxleven / 100) * 20);
                     if leven < ondervijf and leven ~= 0 then
                         waar = true;
                     end
                 end
             end
         end
    
         if (event == "PLAYER_ENTERING_WORLD") then
             PlaySoundFile("Interface\\AddOns\\WillemSound\\outofgum.wav")
         end
    
         if (event == "PLAYER_ENTERING_BATTLEGROUND") then
             PlaySoundFile("Interface\\AddOns\\WillemSound\\medieval.wav")
         end
     end
    
     frame:SetScript("OnEvent", eventHandler);
    
  2. A few things, first, if you're going to paste code, please figure out how to use the editor and the code function before you to do it again. I can't imagine that was very fun for you, and it was near impossible to read. I've fixed it so that is displays properly. All you have to do is paste the code, then select it with your mouse, and click the 'code' button once. That's it.

    As for the code, what isn't working? Are you getting any errors? Is your code being run? Some information would help, because I don't have a ton of time to load up my game and try this for myself. I'd never get any work done if I tried to do that.

  3. If I type this

     local frame = CreateFrame("FRAME", "FooAddonFrame");
     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     local guid = UnitGUID("player");
     local waar = false;
     local function eventHandler(self, event, ...)
      local lol = select(2, ...)
      local guidlol = select(3, ...)
      if guid == guidlol then
      if lol == "SPELL_HEAL" then
        local lol2 = select(15, ...)
        if lol2 == 1 then
        PlaySoundFile("Interface\\AddOns\\WillemSound\\megaheal.wav")
        end
        if waar == true then
         PlaySoundFile("Interface\\AddOns\\WillemSound\\lifesaver.wav");
         waar = false;
        end
      end
      if lol == "SPELL_CAST_START" then
      local leven = UnitHealth("mouseover");
      local maxleven = UnitHealthMax("mouseover");
      local ondervijf = ((maxleven / 100) * 20);
      if leven < ondervijf and leven ~= 0 then
      waar = true;
      end
      end
     end
     end
     frame:SetScript("OnEvent", eventHandler);
    

    it works and gives sounds when heals crit or target under 20% is healed. But when I add the pieces of code from above nothing no longer works, no sounds but no lua error messages.

    And as for the original post, thanks for the info.

  4. Again, you need to do some troubleshooting on your own. Is your conditional getting called? If not, why not? Print the values you're comparing and see if they're what they're supposed to be? There is nothing 100% obvious that I see you doing wrong, but I'm hardly a compiler and API for WoW =)

  5. Strange, when I put a print("something"); line of code after the eventhandler function like this

     local frame = CreateFrame("FRAME", "FooAddonFrame");
     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     frame:RegisterEvent("PLAYER_ENTERING_WORLD");
     frame:RegisterEvent("PLAYER_ENTERING_BATTLEGROUND");
     local guid = UnitGUID("player");
     local waar = false;
     local function eventHandler(self, event, ...)
     print("something");
     ...rest of code...
    

    it doesnt even print it while the event handler should be called when the world is entered. strange. Any ideas?

  6. Nope, but I'd ensure you're catching errors, so install something like BugSack and BugGrabber that ensures errors are grabbed early enough. It's pretty impossible for me to remotely debug this.

  7. Thanks ill try the bugsack addon. http://rapidshare.com/files/418103430/WillemSoundBuggy.zip for those who can use the full addon map

    edit: no errors from my addon where caught by buggrabber

  8. I'm not sure mate. Make sure your code is being run in the first place, and put some debug messages to see what's actually happening.

  9. after couple debugging runs and some luck I got it to work. Thnx for the help man