CMD:report(playerid,o[])
{
new msg[80],str[128],pname[MAX_PLAYER_NAME];
if(sscanf(o,"s[80]",msg)) return SCM(playerid,COLOR_LIGHTBLUE,"USAGE:/report [text]");
if(rcd[playerid] == 1) return SCM(playerid,COLOR_LIGHTBLUE,"You must wait 15 seconds in order to send another report!");
else
{
GetPlayerName(playerid,pname,sizeof(pname));
format(str,sizeof(str),"Report from %s(%i): %s",pname,playerid,msg);
SAM(COLOR_AQUA,str);
SCM(playerid,COLOR_YELLOW,"Your report has been sent to the administrators online.");
rcd[playerid] = 1;
delay:rtimer(playerid);
}
return 1;
}
timer rtimer[10000](playerid)
{
rcd[playerid] = 0;
SCM(playerid,COLOR_GREEN,"You may send another report now!");
}
rtimer(playerid);
repeat rtimer(playerid);
Timers aren't needed you could just use GetTime() and compare the current time with the one you stored in a variable when the user first reported, if 15 seconds or above allow the user to report again.
|
Could you show me a littttttle example please, I have never used that function before, only if possible
![]() |
new ReportCheck[MAX_PLAYERS]; // Global
// Inside report command:
new current_time = gettime();
if(!ReportCheck[playerid] || ReportCheck[playerid] >= current_time + 15) {
ReportCheck[playerid] = current_time;
// The report code in here
}
else {
// Send message telling the user that he has to wait 15 seconds.
}
pawn Код:
|
CMD:report(playerid,o[])
{
new rcd[MAX_PLAYERS];
new ctime = gettime();
new msg[80],str[128],pname[MAX_PLAYER_NAME];
if(sscanf(o,"s[80]",msg)) return SCM(playerid,COLOR_LIGHTBLUE,"USAGE:/report [text]");
if(!rcd[playerid] || rcd[playerid] >= ctime + 15)
{
rcd[playerid] = ctime;
GetPlayerName(playerid,pname,sizeof(pname));
format(str,sizeof(str),"Report from %s(%i): %s",pname,playerid,msg);
SAM(COLOR_AQUA,str);
SCM(playerid,COLOR_YELLOW,"Your report has been sent to the online administrators.");
}
else
{
SCM(playerid,COLOR_LIGHTBLUE,"You must wait 15 seconds in order to send another report!");
}
rcd is a global variable meaning you create it outside of any functions/commands.
|
new rcd[MAX_PLAYERS];
CMD:report(playerid,o[])
{
new msg[80],str[128],pname[MAX_PLAYER_NAME];
if(sscanf(o,"s[80]",msg)) return SCM(playerid,COLOR_LIGHTBLUE,"USAGE:/report [text]");
if(!rcd[playerid] || gettime() >= rcd[playerid] + 15)
{
rcd[playerid] = gettime();
GetPlayerName(playerid,pname,sizeof(pname));
format(str,sizeof(str),"Report from %s(%i): %s",pname,playerid,msg);
SAM(COLOR_AQUA,str);
SCM(playerid,COLOR_YELLOW,"Your report has been sent to the online administrators.");
}
else
{
SCM(playerid,COLOR_LIGHTBLUE,"You must wait 15 seconds in order to send another report!");
}
return true;
}