View Single Post
06-27-16, 12:35 AM   #5
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Fizzlemizz View Post
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?
  Reply With Quote