12.11.2014, 19:48
Is there a way to kill afk players? I see this on many servers and i want to know what code is used for this thing.
Sure there is. It would be useful to search the forums for an AFK script tutorial. Usually most of them will kick the inactive player, but you could just change the function to instead of kicking them, to set their HP to zero. Here, I'll link you to one:
https://sampforum.blast.hk/showthread.php?tid=381125 |
new AntiAFK[MAX_PLAYERS];
new AFKTIMER[MAX_PLAYERS];
#define MAX_AFK_TIME 5
forward OnPlayerAFKcheck(playerid)
{
AntiAFK[playerid]++;
if(AntiAFK[playerid]>MAX_AFK_TIME)
{
// ur code
//SetPlayerHealth(playerid,0.0);
}
}
public OnPlayerConnect(playerid)
{
AFKTIMER[playerid]=SetTimerEx("OnPlayerAFKcheck",1000,true, "d", playerid);
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
KillTimer(AFKTIMER[playerid]);
AntiAFK[playerid]=0;
return 1;
}
public OnPlayerUpdate(playerid)
{
AntiAFK[playerid]=0;
return 1;
}