Quote:
Originally Posted by oMa37
Stop death abuse in your server!
PHP код:
#include <a_samp>
new AbuseTick[MAX_PLAYERS];
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) {
AbuseTick[playerid] = gettime();
return 1;
}
DisableCommand(playerid, time) { // Time in seconds
return (gettime() - AbuseTick[playerid] < time);
}
// Example Usage;
CMD:teleport(playerid) {
if(DisableCommand(playerid, 15)) return SendClientMessage(playerid, -1, "You have been attacked by another player.");
// OR ...
if(gettime() - AbuseTick[playerid] < 15) /* 15 Seconds */ return SendClientMessage(playerid, -1, "You have been attacked by another player.");
// Other stuff
return 1;
}
Stop command abuse in your server!
PHP код:
#include <a_samp>
new CoolDownCMD[MAX_PLAYERS];
CMD:teleport(playerid) {
new string[45],
currenttime = gettime();
new cooldown = (CoolDownCMD[playerid] + 120 /* 120 is the seconds - 2 minutes | you can change it to whatever you want */) - currenttime;
format(string, sizeof(string),"You have to wait %d:%02d minutes/seconds", cooldown / 60, cooldown % 60);
if(currenttime < (CoolDownCMD[playerid] + 120 /* 120 is the seconds - 2 minutes | you can change it to whatever you want */)) return SendClientMessage(playerid, -1, string);
CoolDownCMD[playerid] = gettime();
// Other stuff
return 1;
}
|
You'll have to check if the player is attacked by someone (issuerid != INVALID_PLAYER_ID).
To stop command spams and death evade, you could use the callbacks that are called when the command is attempted. Having these functions in every commands isn't the right way. Simply update the last command call under the callback that's called AFTER the command is performed.
I do realise there are other command processors but I've been talking about zcmd. If the ones you're using doesn't provide such features, I wouldn't recommend their usage at all.