PLAYER_XP_UPDATE fires multiple times in some cases

Hi there!

I’m working on fixind / updating the functionality of my simple addon Remaining XP, and I have discovered that when PLAYER_XP_UPDATE is being called, it fires

  • 2 times after killing a mob
  • 2 times after gaining a level (4 times if the level-up xp is gained from a mob kill)
  • and only one time after completing a quest, gathering an herb (and probably anything else), opening a treasure and discovering a new location (these were the only cases I was able to test so far).

I haven’t yet been able to determine why this would be the case. Does anyone know?

Relevant code snippets:
remainingXP:RegisterEvent("PLAYER_XP_UPDATE")
remainingXP:SetScript("OnEvent", function(self, event, ...)
    return self[event] and self[event](self, ...)
end)

function remainingXP:PLAYER_XP_UPDATE()
    UpdateXP()
    print("PLAYER_XP_UPDATE")
end

“PLAYER_XP_UPDATE” is printed as many times as I described above when the specific events occur.

At least this part I can explain, it fires for both the “player” and “nameplateN” (personal resource display) UnitIds, you can debug this with /etrace

function remainingXP:PLAYER_XP_UPDATE(unit)
	if unit == "player" then
		UpdateXP()
		print("PLAYER_XP_UPDATE")
	end
end
1 Like

That indeed did the trick for mob kills.
Now leveling up only fires PLAYER_XP_UPDATE twice, as anything else (like turning in a quest).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.