local MX = LibStub("AceAddon-3.0"):GetAddon("MxW.Farm"); local L = LibStub("AceLocale-3.0"):GetLocale("MxW.Farm"); local PLAYER_MONEY_Frame = CreateFrame("Frame") PLAYER_MONEY_Frame:RegisterEvent("PLAYER_MONEY") PLAYER_MONEY_Frame:SetScript("OnEvent", function(self, event, arg1) if event == "PLAYER_MONEY" then local DiffGold = 0 local NewGold = GetMoney() -- Get the player gold after the event DiffGold = NewGold - CurrentGold -- Get the gold difference if (DiffGold > 0) then -- Gold gain -- Write to SavedVariables MxW_MonthlyGlobal = MxW_MonthlyGlobal + DiffGold; MxW_DailyGlobal = MxW_DailyGlobal + DiffGold; MX:RefreshDisplay() elseif (DiffGold <= 0) then -- Gold lost end CurrentGold = GetMoney() DiffGold = 0 end end)