View Single Post
03-18-22, 04:24 AM   #8
DonnieDice
A Murloc Raider
AddOn Author - Click to view addons
Join Date: May 2019
Posts: 6
Originally Posted by SDPhantom View Post
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);
Just tested this and no dice. I'll test it again in a bit just to be doubly sure, maybe I did something wrong.

Last edited by DonnieDice : 03-18-22 at 04:37 AM.
  Reply With Quote