Can't /report yourself? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can't /report yourself? (
/showthread.php?tid=278600)
Can't /report yourself? -
Tigerbeast11 - 23.08.2011
I have this code for a /report command:
pawn Code:
dcmd_report(playerid, params[])
{
new tmp[256], idx;
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x555252AA, "Syntax Error: /report [player] [reason]");
return 1;
}else{
new pid = strval(tmp);
tmp = strrest(params, idx);
if(!IsPlayerConnected(pid)){
SendClientMessage(playerid, 0x555252AA, "ERROR: Invalid Player");
return 1;
}else{
if(!strlen(tmp)){
SendClientMessage(playerid, 0x555252AA, "Syntax Error: /report [player] [reason]");
return 1;
}else{
new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[200];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(pid, name2, sizeof(name2));
format(string, sizeof(string), "[REPORT]%s [ID:%d] reported %s [ID:%d] for: %s", name, playerid, name2, pid, tmp);
SendClientMessage(playerid,grey,"Thank you for your report. It has been sent to online admins.");
SendMessageToAdmins(string);
}
}
}
return 1;
}
But the problem is, you can /report yourself, which makes it easy to abuse this command. What would I have to do to make sure you can't report yourself?
Re: Can't /report yourself? -
CyNiC - 23.08.2011
Add this line under this line: "pid = strval(tmp);"
pawn Code:
if(pid == playerid) return SendClientMessage(playerid, 0x555252AA, "Error: You can't report your self!");
Re: Can't /report yourself? -
=WoR=Varth - 23.08.2011
pawn Code:
dcmd_report(playerid, params[])
{
new tmp[256], idx;
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x555252AA, "Syntax Error: /report [player] [reason]");
return 1;
}else{
new pid = strval(tmp);
tmp = strrest(params, idx);
if(!IsPlayerConnected(pid) || playerid == pid){
SendClientMessage(playerid, 0x555252AA, "ERROR: Invalid Player");
return 1;
}else{
if(!strlen(tmp)){
SendClientMessage(playerid, 0x555252AA, "Syntax Error: /report [player] [reason]");
return 1;
}else{
new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME], string[200];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(pid, name2, sizeof(name2));
format(string, sizeof(string), "[REPORT]%s [ID:%d] reported %s [ID:%d] for: %s", name, playerid, name2, pid, tmp);
SendClientMessage(playerid,grey,"Thank you for your report. It has been sent to online admins.");
SendMessageToAdmins(string);
}
}
}
return 1;
}
Re: Can't /report yourself? -
Tigerbeast11 - 23.08.2011
Thanks! Have a +rep!