-
Posted by chocobar on Sun, 20 Jan 2013 20:52:48
Hello everybody,
I would like some help on me problem, please.
local EventFrame = CreateFrame("Frame") local teamName, teamSize, teamRating, teamPlayed, teamWins, seasonTeamPlayed, seasonTeamWins, playerPlayed, seasonPlayerPlayed, teamRank, playerRating, bg_red, bg_green, bg_blue, emblem, emblem_red, emblem_green, emblem_blue, border, border_red, border_green, border_blue = GetArenaTeam(1) EventFrame:RegisterEvent("PLAYER_LOGIN") EventFrame:SetScript("OnEvent", function(self,event,...) ChatFrame1:AddMessage("xd" ..teamName); ChatFrame1:AddMessage("lol"); end)
My variables are all init at 0 and when i try to print teamName that print nothing at all.
Thank you.
-
Posted by jnwhiteh on Mon, 21 Jan 2013 06:44:02
Hello everybody,
I would like some help on me problem, please.
local EventFrame = CreateFrame("Frame") local teamName, teamSize, teamRating, teamPlayed, teamWins, seasonTeamPlayed, seasonTeamWins, playerPlayed, seasonPlayerPlayed, teamRank, playerRating, bg_red, bg_green, bg_blue, emblem, emblem_red, emblem_green, emblem_blue, border, border_red, border_green, border_blue = GetArenaTeam(1) EventFrame:RegisterEvent("PLAYER_LOGIN") EventFrame:SetScript("OnEvent", function(self,event,...) ChatFrame1:AddMessage("xd" ..teamName); ChatFrame1:AddMessage("lol"); end)
My variables are all init at 0 and when i try to print teamName that print nothing at all.
Thank you.
A few things: most game information is not truly available until after
PLAYER_LOGIN
, that's why you normally see this pattern. There's no reason to pre-fetch the information (which is wrong) and then print it later. Fetch it when it is needed and you know you can get it.Let's start with something simple:
EventFrame = CreateFrame("Frame") local function onEvent(self, event, ...) if event == "PLAYER_LOGIN" then local teamName = GetArenaTeam(1) print("Team name is: " .. tostring(teamName)) end end) EventFrame:SetScript("OnEvent", onEvent) EventFrame:RegisterEvent("PLAYER_LOGIN") -- Depending on when you run this code, especially if this is a load on demand addon -- the PLAYER_LOGIN event may have already fired. You can run it manually in that -- case. if IsLoggedIn() then onEvent(EventFrame, "PLAYER_LOGIN") end
-
Posted by chocobar on Mon, 21 Jan 2013 12:05:00
Thank you for you'r answer.
Yes it seems just logical I don't know why I didn't thought about that
Thanks you a lot I'll try this right now
-
Posted by chocobar on Wed, 23 Jan 2013 19:43:36
Hi again,
I tried to get my arena infos very very late, when I go in combat, to be sure that I could get arenas informations but thats still dont work :(
local EventFrame = CreateFrame("Frame") local teamName, Size EventFrame:RegisterEvent("PLAYER_ENTER_COMBAT") EventFrame:SetScript("OnEvent", function(self,event,...) teamName, Size = GetArenaTeam(2) ChatFrame1:AddMessage("Arena book is ready, ".. Size..".") end)
-
Posted by jnwhiteh on Wed, 23 Jan 2013 20:12:36
That isn't the 'go into combat event'. That is
PLAYER_REGEN_DISABLED
, but even that is not 100%. Why not one of the arena events, such asARENA_TEAM_ROSTER_UPDATE
? -
Posted by chocobar on Thu, 24 Jan 2013 18:13:54
Hi, i tried what you said, but it still doest work I wonder if this function is not broken.
-
Posted by jnwhiteh on Thu, 24 Jan 2013 18:19:12
That seems unlikely, given that the UI uses it.
-
Posted by chocobar on Thu, 24 Jan 2013 19:12:24
I found a solution, i just used ARENATEAMUPDATE Thank you a lot.