17.12.2010, 16:10
You may wish to study this code further. This does all you wanted it to do, even though it looks completely different.
pawn Code:
dcmd_report(playerid, params[]) // Credits to "RealCop228" //
{
new id, message[118], string[128];
if(sscanf(params, "us[118]", id, message)) // If the params don't match up, we'll tell them the correct syntax/usage.
return SendClientMessage(playerid, COLOR_ORANGE, "SYNTAX: /report [nick/id] [comment]");
if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) // We'll check if the reported player is invalid, or not connected.
return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected!");
if(strlen(message) > 118) // We don't want to send a message which won't fit on the line being sent to the admins!
return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Comment Length! Max Characters: 118");
new pName[MAX_PLAYER_NAME], iName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(id, iName, sizeof(iName));
// Let's send to the admins, IRC and the server console!
format(string, sizeof(string), "REPORT: %s(%d) has reported %s(%d).", pName, playerid, iName, id);
SendMessageToAdmins(COLOR_RED, string);
print(string); ReportLog(string); IRC_GroupSay(gGroupOD, IRC_CHANNEL, string); // You really don't need to format 2 more strings...
format(string, sizeof(string), "Comment: %s", comment);
SendMessageToAdmins(COLOR_RED, string);
print(string); ReportLog(string); IRC_GroupSay(gGroupOD, IRC_CHANNEL, string);
// Let's notify a successful report!
format(string, sizeof(string), "Your report on \"%s(%d)\" has been logged and sent to the online admins. Thank you!", iName, id);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}