pawn Code:
if(strcmp(cmd, "/report", true)==0) if(Logged[playerid] == 1)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[ ! ] USAGE: /report [playerid] [message]");
new giveplayerid = strval(tmp);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= \' \'))
{
idx++;
}
new offset = idx;
new result[64];
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 [playerid] [message]");
return 1;
}
new str[128];
format(str, 128, "[REPORT] %s[%d] has reported %s[%d] for %s",PlayerName(playerid),playerid,PlayerName(giveplayerid),giveplayerid, result);
for(new i; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i) && IsPlayerAdmin(i)){
SendClientMessage(i, COLOR_RED, str);
new File: file = fopen("Reports.txt",io_read);
if(!file){fcreate("Reports.txt");}
format(str,sizeof(str),"[ ! ] %s has reported %s for %s
",PlayerName(playerid),PlayerName(giveplayerid),result);
fwrite(file,str);
fclose(file);
}}
SendClientMessage(playerid, COLOR_GREEN, "[ ! ] Report sent to online admins!");
return 1;
}