Originally Posted by Kanegasi
Stats may not be available right at login. Plus, they could change with procs and other events during play. Use the event COMBAT_RATING_UPDATE instead. This could get spammy in a group, so you may have to check the unit return.
Lua Code:
c:SetScript("OnEvent", function(self,event,unit) if unit=="player" then crit = round(GetCritChance(), 3) c.text:SetText( "Crit: " .. crit ) end end)
I just noticed that you're getting crit only once, which explains the 0 since you're getting crit before you even login. The OnEvent is just setting the same number over and over again if you use the event I suggested. I put another crit= inside the OnEvent for you. You can even skip using a crit variable and just put the round() call in directly.
Lua Code:
c:SetScript("OnEvent", function(self,event,unit) if unit=="player" then c.text:SetText( "Crit: " .. round(GetCritChance(), 3) ) end end)
|
I think OP would want to check PLAYER_ENTERING_WORLD as well if he wants the stats available right away. I'm probably wrong but I believe COMBAT_RATING_UPDATE only fires in combat.