View Single Post
03-17-22, 06:15 AM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Here's an example I came up with. It's based off how ReputationFrame updates and keeps track of rep by ID to avoid name collisions.
Lua Code:
  1. local TrackedFactions={};
  2. local EventFrame=CreateFrame("Frame");
  3. EventFrame:RegisterEvent("PLAYER_LOGIN");-- Player login
  4. EventFrame:RegisterEvent("UPDATE_FACTION");--   Kill rep
  5. EventFrame:RegisterEvent("QUEST_LOG_UPDATE");-- Quest rep
  6.  
  7. EventFrame:SetScript("OnEvent",function()
  8.     for i=1,GetNumFactions() do
  9.         local _,_,newstanding,_,_,_,_,_,_,_,hasrep,_,_,faction=GetFactionInfo(i);
  10.         if hasrep and faction and (newstanding or 0)>0 then--   Make sure we have the info we need and standing isn't UNKNOWN (0)
  11.             local oldstanding=TrackedFactions[faction];
  12.             if oldstanding and oldstanding<newstanding then--   Check if standing went up (allow same code to initialize tracking)
  13.                 PlaySoundFile("Interface\\AddOns\\YourAddOn\\YourSoundFile.ogg");
  14.             end
  15.  
  16.             TrackedFactions[faction]=newstanding;-- Update standing
  17.         end
  18.     end
  19. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote