roaddog Posted May 7, 2014 Share Posted May 7, 2014 Hello all today i bring to you this problem, and I dont know how to fix this cuz you know im still learning function afkList (player, command) players = getPlayerFromName("player") for i,thePlayer in ipairs(players) do if (getElementData(thePlayer, "AFK") > 0) then outputChatBox("List of AFK Players :", player, 50, 255, 50, true) outputChatBox("---------------------",player, 50,255, 50, true) outputChatBox("*"..getPlayerName(thePlayer).."", player, 55, 255, 55, true) elseif (getElementData(thePlayer, "AFK") == 0) then outputChatBox("There's no Players AFK", player, 55, 255,55, true) end end end addCommandHandler("afklist", afkList) and debug script says Error bad argument #1 ipairs (table expected, got boolean) Link to comment
Castillo Posted May 7, 2014 Share Posted May 7, 2014 That's because getPlayerFromName obtains a player userdata from it's name. You must use getElementsByType instead. Link to comment
WASSIm. Posted May 7, 2014 Share Posted May 7, 2014 try this function afkList (player) local afkplayers = { } for i,thePlayer in ipairs(getElementsByType("player")) do if (getElementData(thePlayer, "AFK") > 0) then table.insert(afkplayers, thePlayer) end end if (#afkplayers > 0) then outputChatBox("List of AFK Players:", player, 50, 255, 50, true) outputChatBox("---------------------",player, 50,255, 50, true) for i,thePlayer in ipairs(afkplayers) do local name = getPlayerName(thePlayer) outputChatBox("*"..name, thePlayer, 55, 255,55, true) end outputChatBox("---------------------",player, 50,255, 50, true) else outputChatBox("There's no Players AFK", player, 55, 255,55, true) end end addCommandHandler("afklist", afkList) Link to comment
roaddog Posted May 7, 2014 Author Share Posted May 7, 2014 (edited) Thanks wassim, but it got error, line 4 attempt to compare number with boolean Edited May 7, 2014 by Guest Link to comment
WASSIm. Posted May 7, 2014 Share Posted May 7, 2014 (edited) Thanks wassim, but it got error, attempt to compare number with boolean EDIT try this function afkList (player) local afkplayers = { } for i,thePlayer in ipairs(getElementsByType("player")) do if (getElementData(thePlayer, "AFK")) then table.insert(afkplayers, thePlayer) end end if (#afkplayers > 0) then outputChatBox("List of AFK Players:", player, 50, 255, 50, true) outputChatBox("---------------------",player, 50,255, 50, true) for i,thePlayer in ipairs(afkplayers) do local name = getPlayerName(thePlayer) outputChatBox("*"..name, thePlayer, 55, 255,55, true) end outputChatBox("---------------------",player, 50,255, 50, true) else outputChatBox("There's no Players AFK", player, 55, 255,55, true) end end addCommandHandler("afklist", afkList) Edited May 7, 2014 by Guest Link to comment
roaddog Posted May 7, 2014 Author Share Posted May 7, 2014 Line 4 attempt to compare number with boolean Link to comment
roaddog Posted May 7, 2014 Author Share Posted May 7, 2014 Thanks wassim, but it got error, attempt to compare number with boolean EDIT try this function afkList (player) local afkplayers = { } for i,thePlayer in ipairs(getElementsByType("player")) do if (getElementData(thePlayer, "AFK")) then table.insert(afkplayers, thePlayer) end end if (#afkplayers > 0) then outputChatBox("List of AFK Players:", player, 50, 255, 50, true) outputChatBox("---------------------",player, 50,255, 50, true) for i,thePlayer in ipairs(afkplayers) do local name = getPlayerName(thePlayer) outputChatBox("*"..name, thePlayer, 55, 255,55, true) end outputChatBox("---------------------",player, 50,255, 50, true) else outputChatBox("There's no Players AFK", player, 55, 255,55, true) end end addCommandHandler("afklist", afkList) Aw Very nice, Thank you it works It was so fast Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now