View Single Post
03-20-18, 07:05 AM   #7
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Originally Posted by Kanegasi View Post
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:
  1. c:SetScript("OnEvent", function(self,event,unit)
  2.     if unit=="player" then
  3.         crit = round(GetCritChance(), 3)
  4.         c.text:SetText( "Crit: " .. crit )
  5.     end
  6. 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:
  1. c:SetScript("OnEvent", function(self,event,unit)
  2.     if unit=="player" then
  3.         c.text:SetText( "Crit: " .. round(GetCritChance(), 3) )
  4.     end
  5. 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.
__________________
Tweets YouTube Website
  Reply With Quote