I'm getting this error: "bad argument #1 to 'pairs' (table expected, got nil)"
I'm pretty new to working with tables, so maybe I'm just not getting somthing here...
Here's the code:
Code:
local afkPlayerName, afkPlayersList = {}
local function isStillAfk(afkPlayerName) --Just checking if you're still flagged AFK
for k,v in pairs(afkPlayersList) do
if k == afkPlayerName and v == "afk" then
return true
else
return false
end
end
end
local function findAfkMessage(self, event, msg, player, ...) --Looks for the AFK spam in the chat frame
if string.find(msg, "is Away From Keyboard:") then
if not isStillAfk(player) then
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFC0CB"..player.." is AFK.")
afkPlayersList[player] = "afk"
--[[elseif isStillAfk(player) then
afkPlayerName = player--]]
end
return true
else
if isStillAfk(player) then
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFC0CB"..player.." is no longer AFK.")
end
afkPlayersList[player] = "not afk"
return false
end
end
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", findAfkMessage)
Any insight you can give me would be great. Thanx