Anti afk abuse
#5

Player takes damage in OnPlayerTakeDamage. You could also technically use OnPlayerGiveDamage.

If the player was damaged by another player, update their 'last damaged' variable to the current timestamp.

PHP код:
if((gettime() - variable[playerid]) < duration// Player has not waited long enough 
Example:
PHP код:
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID && issuerid != playerid// The player was damaged by another player
    
{
        
SetPVarInt(playerid"LastDamaged"gettime());
    }
    return 
1;
}
CMD:afk(playeridparams[])
{
    if((
gettime() - GetPVarInt(playerid"LastDamaged")) < 60) return SendClientMessage(playerid, -1"You have been damaged recently, you can't use this command.");
    
// Rest of command...

https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/GetTickCount
Reply


Messages In This Thread
Anti afk abuse - by 1fret - 22.10.2016, 20:44
Re: Anti afk abuse - by ThatFag - 22.10.2016, 20:56
Re: Anti afk abuse - by 1fret - 22.10.2016, 21:06
Re: Anti afk abuse - by ThatFag - 22.10.2016, 21:12
Re: Anti afk abuse - by Threshold - 23.10.2016, 06:14
Re: Anti afk abuse - by 1fret - 23.10.2016, 22:38
Re: Anti afk abuse [SOLVED] - by 1fret - 23.10.2016, 22:49

Forum Jump:


Users browsing this thread: 2 Guest(s)