roaddog Posted May 7, 2014 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) You gone learn today. I work my ass off, but I still can't pay tho.
Castillo Posted May 7, 2014 Posted May 7, 2014 That's because getPlayerFromName obtains a player userdata from it's name. You must use getElementsByType instead. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
WASSIm. Posted May 7, 2014 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)
roaddog Posted May 7, 2014 Author 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 You gone learn today. I work my ass off, but I still can't pay tho.
WASSIm. Posted May 7, 2014 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
roaddog Posted May 7, 2014 Author Posted May 7, 2014 Line 4 attempt to compare number with boolean You gone learn today. I work my ass off, but I still can't pay tho.
roaddog Posted May 7, 2014 Author 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 You gone learn today. I work my ass off, but I still can't pay tho.
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