23.10.2016, 06:14
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.
Example:
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/GetTickCount
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
PHP код:
OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && issuerid != playerid) // The player was damaged by another player
{
SetPVarInt(playerid, "LastDamaged", gettime());
}
return 1;
}
CMD:afk(playerid, params[])
{
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/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/GetTickCount