xeon17 Posted January 5, 2015 Share Posted January 5, 2015 (edited) Hello there, I got a problem , i'm creating a anti afk system but the problem is after the player get killed when he is afk 1 second, how to stop the loop , to make him get killed again when he is afk 2 seconds or 3 seconds and not 1 because he is already killed because he was afk 1 second. Help. function kick_afk() for index, player in ipairs(getElementsByType("player")) do if getElementData(player,"invincible") then return end if( getPlayerIdleTime(player) > 1000 ) then killPed(player) outputChatBox("#696969[sERVER] #FFFFFFPlayer #FF0000 "..getPlayerName(player).." #FFFFFF have been killed #ff0000 AFK:[1/3] ",root,_,_,_,true) elseif ( getPlayerIdleTime(player) > 2000 ) then killPed(player) outputChatBox("#696969[sERVER] #FFFFFFPlayer #FF0000 "..getPlayerName(player).." #FFFFFF have been killed #ff0000 AFK:[2/3] ",root,_,_,_,true) elseif ( getPlayerIdleTime(player) > 3000 ) then outputChatBox("#696969[sERVER] #FFFFFFPlayer #FF0000"..getPlayerName(player).." #FFFFFF have been kicked #ff0000 AFK:[3/3] ",root,_,_,_,true) kickPlayer(player, "server", "you are afk") end end end setTimer(kick_afk, 5000, 0) Edited January 5, 2015 by Guest Link to comment
Castillo Posted January 5, 2015 Share Posted January 5, 2015 I don't understand the problem, nor why would you kill someone for being idle for a second, it's rather stupid. Link to comment
xeon17 Posted January 5, 2015 Author Share Posted January 5, 2015 Doing it for faster testing , i want when the player once is killed because he was afk for 1 second , he get killed again when he was afk 2 seconds, but how?... http://imgur.com/6jkVmFj.png Link to comment
Castillo Posted January 5, 2015 Share Posted January 5, 2015 You mean that you want a warning system? use a table, when the player gets killed the first time, add the player to the table, and when you check the AFK time, also check the warning level. Link to comment
xeon17 Posted January 5, 2015 Author Share Posted January 5, 2015 Great idea , Thanks! solved. 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