Originally Posted by Fizzlemizz
If you have/want "PLAYER_LOGOUT" as the only registered event, get rid of
Code:
if event == "PLAYER_LOGOUT" then
and it's corresponding end.
Otherwise change the function prototype to:
Code:
local function ResourceTrackFrame_OnEvent(self, event, arg1)
|
Wow... adding "self" to parameter lists did do the trick!
Code:
local ResourceTrackFrame = CreateFrame("Frame");
ResourceTrackFrame:RegisterEvent("PLAYER_LOGOUT");
local function ResourceTrackFrame_OnEvent(self, event, arg1)
if event == "PLAYER_LOGOUT" then
realm = GetRealmName();
name = UnitName("player");
_, englishClass = UnitClass("player");
_, currentAmount = GetCurrencyInfo(824);
if type(Resource) ~= "table" then
Resource = {};
end
if type(Resource[realm]) ~= "table" then
Resource[realm] = {};
end
if type(Resource[realm][name]) ~= "table" then
Resource[realm][name] = {};
end
Resource[realm][name]["Class"] = englishClass;
Resource[realm][name]["GarrisonResource"] = currentAmount;
end
end
ResourceTrackFrame:SetScript("OnEvent", ResourceTrackFrame_OnEvent);
Do you know what was causing the problem?