/report bug - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /report bug (
/showthread.php?tid=476550)
/report bug -
whando - 18.11.2013
When I use /report *reported playerid* *reason* I can insert whatever I want at the playerid, how could I get it that I can only enter a valid player ID/name? And if someone isn't logged in it returns blabla player is not logged in?
Код:
if(strcmp(cmd, "/report", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(JustReported[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "Wait 20 seconds after sending a next /report ! ");
return 1;
}
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
if(IsPlayerNPC(giveplayerid)) return 1;
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /report [player] [reason]");
return 1;
}
if(PlayerInfo[playerid][pReportMuted] == 1)
{
return SendClientMessage(playerid, COLOR_RED, "You are muted from sending any /reports!");
}
JustReported[playerid] = 1;
SetTimerEx("ReportReset", 20000, false, "i", playerid);
format(string, sizeof(string), "%s reporting %s: %s", RemoveUnderScore(playerid), RPN(giveplayerid), (result));
ABroadCast(COLOR_RED, string, 1);
SendClientMessage(playerid, COLOR_YELLOW, "Your report was succesfully sent.");
Reported[playerid] = 1;
}
return 1;
}
AW: /report bug -
Skimmer - 18.11.2013
Just add this below IsPlayerNPC.
pawn Код:
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
if(PlayerInfo[giveplayerid][pLogged] == 0) return SendClientMessage(playerid, COLOR_RED, "Player is not logged in.");
Also you don't need to create extra timer to reset the JustReported variable.
Simple create a variable, which saves the time of using this command.
Example
pawn Код:
JustReported[playerid] = gettime();
pawn Код:
if((gettime() - JustReported[playerid]) < 20) return SendClientMessage(playerid, COLOR_GREY, "Wait 20 seconds after sending a next /report ! ");