new ReportTime[MAX_PLAYERS];
CMD:report(playerid, params[])
{
new string[128];
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
if(AntiAdv(playerid, params)) return 1;
if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
if(ReportTime[playerid] > 0)
{
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
SendReportToQue(playerid, params);
Log("logs/reports.log", string);
SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
ReportTime[playerid] = 25;
SetTimerEx("ReportTimer", 1000, false, "i", playerid);
return 1;
}
if(gettime() - ReportTime[playerid] < 25) return SendClientMessage(playerid, -1, "You can only report players every 25 seconds!"); // Player has reported a player within the last 25 seconds.
ReportTime[playerid] = gettime(); //The player has now reported a player
Use gettime instead, then you dont need any timers.
pawn Код:
|
CMD:report(playerid, params[])
{
new string[128];
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
if(AntiAdv(playerid, params)) return 1;
if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
if(ReportTime[playerid] > 0)
{
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
SendReportToQue(playerid, params);
Log("logs/reports.log", string);
SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
ReportTime[playerid] = 25;
SetTimerEx("ReportTimer", 1000, false, "i", playerid);
foreach(Player, i)
if(ReportTime[i] > 0)
{
ReportTime[i]--;
}
return 1;
}
SetTimerEx("ReportTimer", 1000, false, "ii", playerid, 25); // In your report command, 25 secs
forward ReportTimer(playerid, seconds);
public ReportTimer(playerid, seconds)
{
if(!IsPlayerConnected(playerid)) return 1; // If player left server, no need to keep running this timer..
ReportTime[playerid] = seconds; // This is how many seconds player have to wait b4 report again
if(seconds != 0) SetTimerEx("ReportTimer", 1000, false, "ii", playerid, seconds-1); // 1 sec timer, that decreases
}
Why would you use a Timer for this? Richie has the right idea if your using a timer your doing it assbackwards.
|
CMD:report(playerid, params[])
{
new string[128];
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [text]");
if(PlayerInfo[playerid][pRMute] > 0) return SendClientMessage(playerid, COLOR_GREY, "You are muted from reporting.");
if(AntiAdv(playerid, params)) return 1;
if(strlen(params) > 128) return SendClientMessage(playerid, COLOR_GREY, "Maximum characters limit is 128.");
if(gettime() - ReportTime[playerid] < 25)
{
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
}
else
{
SendReportToQue(playerid, params);
Log("logs/reports.log", string);
SendClientMessage(playerid, COLOR_ORANGE, "Your report have been sent to the online admins, Please be patient.");
ReportTime[playerid] = gettime();
}
return 1;
}
pawn Код:
|
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", ReportTime[playerid]);
format(string, sizeof(string), "You need to wait %d more seconds before making a report message again.", 25-(gettime()-ReportTime[playerid]));