18.08.2016, 12:05
Hello,
i made a small cooldown for command report (using help from one of samp forum posts), but it doesnt seems to work, players can spam /report without waiting that 1 minute.
i made a small cooldown for command report (using help from one of samp forum posts), but it doesnt seems to work, players can spam /report without waiting that 1 minute.
PHP код:
COMMAND:report(playerid, params[])
{
new currenttime = gettime();
new commandtime[MAX_PLAYERS];
if(playerData[playerid][playerLoggedIn])
{
if (playerData[playerid][canReport])
{
if(currenttime >= (commandtime[playerid] + 60))
{
new input[120], message[250], ID, playerName[30],adminName[30];
if(sscanf(params, "ds[100]", ID, input ))
{
return SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"report <message>\"");
}
else
{
foreach(Player, i)
{
if(playerData[i][playerLevel] >= 1)
{
GetPlayerName(ID, playerName, sizeof(playerName));
GetPlayerName(playerid, adminName, sizeof(adminName));
format(message, sizeof(message), "{FF0000}[REPORT] Player %s(%i) has reported{FFFFFF} %s(%d) - Reason: %s", playerData[playerid][playerNamee], playerid, playerData[ID][playerNamee],ID, input);
SendClientMessage(i, COLOR_WHITE, message);
commandtime[playerid] = currenttime;
}
}
return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[REPORT] {FFFF00}Your report has been sent to the online administrators.");
}
}
else
{
new str[55];
format(str, sizeof(str), "You cannot use this command for another %d seconds.", ((commandtime[playerid] + 60) - currenttime));
SendClientMessage(playerid, -1, str);
}
}
else
{
return SendClientMessage(playerid, COLOR_WHITE, "{FF0404}[ERROR] {FFFF00}You have been blocked from using report by an administrator.");
}
}
return 1;
}