23.08.2011, 00:08
I have this code for a /report command:
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?
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;
}