Waterflame wrote:I have another question (AddOn related):
In the chat, if I writte:or
- Code: Select all
/run ChatFrame1:AddMessage(UnitLevel("player"))
it will writte the player's level in the chat, but, if I try
- Code: Select all
/script ChatFrame1:AddMessage(UnitLevel("player"))
on the .lua document for an AddOn, it always writtes 0.
- Code: Select all
ChatFrame1:AddMessage(UnitLevel("player"))
It could mean that the addon is being triggered before the player information is even created.
You could try adding a event trigger I.E. PLAYER_ENTERING_WORLD
- Code: Select all
local f = CreateFrame("frame");
f:RegisterEvent("PLAYER_ENTERING_WORLD");
f:SetScript("OnEvent", function()
if event == "PLAYER_ENTERING_WORLD" then
DEFAULT_CHAT_FRAME:AddMessage(UnitLevel("player"));
end
end);