Quantcast WoWInterface - View Single Post - Character Stats not loading on PLAYER_LOGIN
View Single Post
03-18-18, 10:13 AM   #2
Kanegasi
A Firelord
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 482
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)

Last edited by Kanegasi : 03-18-18 at 10:23 AM.
  Reply With Quote