Jump to content

Question


xeon17

Recommended Posts

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 by Guest
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...