Posts: 617
Threads: 129
Joined: Feb 2014
Quote:
Originally Posted by Threshold
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(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/OnPlayerTakeDamage
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/Gettime
https://sampwiki.blast.hk/wiki/GetTickCount
|
I end up using your code, now i want when the player respawn he will be able to use this command.
how would i do that
pawn Код:
// would it be
SetPVarInt(playerid, "LastDamaged", 0);