09.01.2017, 13:34
(
Последний раз редактировалось oMa37; 09.01.2017 в 18:11.
)
Stop death abuse in your server!
PHP код:
#include <a_samp>
new AbuseTick[MAX_PLAYERS];
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart) {
if(issuerid != INVALID_PLAYER_ID) 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;
}