CMD:report(playerid, params[])
{
new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128], reason, iD;
if (sscanf(params, "dz", iD, reason)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: /report [id] [reason]");
if (iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAA3333AA, "Invalid ID.");
if (playerid == iD) return SendClientMessage(playerid, 0xAA3333AA, "You can't report yourself.");
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(iD, aName, sizeof(aName));
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
new zName[MAX_PLAYER_NAME], pFile[256];
GetPlayerName(i, zName, sizeof(zName));
format(pFile, sizeof(pFile), "Users\%s.ini", zName);
if (IsPlayerAdmin(i) || dini_Int(pFile, "AdminLevel") >= 1)
{
format(str, sizeof(str), "%s(%d) has reported %s(%d) for: %s", pName, playerid, aName, iD, reason);
SendClientMessage(i, 0xFFFFFFFF, str);
}
}
}
return 1;
}
CMD:report(playerid, params[]) // States that the command is /report and it 'may' have extra parameters (which it will.)
{
return 1; // Returns 1 and shows that the command is real and must always work.
}
new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128], reason, iD; // Declares the local variables: pName, aName, str, reason, and iD.
if (sscanf(params, "dz", iD, reason)) return SendClientMessage(playerid, 0xAA3333AA, "Usage: /report [id] [reason]"); // States that sscanf is declares that there ARE going to be parameters, and if there aren't any, it'll return a message saying the 'syntax' of the command. The operators "dz" declare that d = integer, and z is a string that states an optional message.
if (iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAA3333AA, "Invalid ID."); // Checks if the ID is invalid, and if so, it'll return a message telling the player who used the command so.
if (playerid == iD) return SendClientMessage(playerid, 0xAA3333AA, "You can't report yourself."); // Checks if the player is trying to report himself, and if so, tell him that he can't report himself.
GetPlayerName(playerid, pName, sizeof(pName)); // Gets the player's name.
GetPlayerName(iD, aName, sizeof(aName)); // Gets the ID's name. (The ID of the player who is being reported).
for (new i = 0; i < MAX_PLAYERS; i++) // Calls the 'for' function, this function states that it will check all player slots and assigns each slot to a variable, in this case, it's going to assign the variable i.
{
if (IsPlayerConnected(i)) // Checks if the slot is being used.
{
new zName[MAX_PLAYER_NAME], pFile[256]; // Declares new definitions.
GetPlayerName(i, zName, sizeof(zName)); // Gets the name of the slots' user.
format(pFile, sizeof(pFile), "Users\%s.ini", zName); // Formats the player file, change what's in the quotes to the correct destination. (This is only needed if you're using DINI);
if (IsPlayerAdmin(i) || dini_Int(pFile, "AdminLevel") >= 1) // Checks if the player is an RCON admin or if the player is an admin on the player's file, (dini_Int is only required if you're using DINI).
{
format(str, sizeof(str), "%s(%d) has reported %s(%d) for: %s", pName, playerid, aName, iD, reason); // formats the variable 'str,' into a string.
SendClientMessage(i, 0xFFFFFFFF, str); // Sends the string to all online admins.
}
}
Maybe some people may find it usefull, but I rather think they will just copy it without thinking also you should use foreach instead of regular player loops; its way more effecient and faster!
|
C:\Users\Max\Desktop\GTA San Andreas\samp03csvr_win32\gamemodes\TDM.pwn(113) : error 029: invalid expression, assumed zero
C:\Users\Max\Desktop\GTA San Andreas\samp03csvr_win32\gamemodes\TDM.pwn(113) : error 017: undefined symbol "cmd_report"
C:\Users\Max\Desktop\GTA San Andreas\samp03csvr_win32\gamemodes\TDM.pwn(113) : error 029: invalid expression, assumed zero
C:\Users\Max\Desktop\GTA San Andreas\samp03csvr_win32\gamemodes\TDM.pwn(113) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors.
CMD:report(playerid, params[])
{
if ( sscanf( params, "us", params[ 0 ], params[ 1 ] ) )
return SendUsage( playerid, "/report <Player's Name/ID> [report message]");
FormMessage( playerid, COLOR_PINK, "You reported %s to the Administrators, the report has been saved into a file!",PlayerName2( params[ 0 ] ) );
new S,M,H,D,Mo,Y,STTRR[512],File:file;
file = fopen("Administration/Extras/Reports.txt", io_append);
getdate(Y,Mo,D),gettime(H,M,S);
format(STTRR, sizeof( STTRR ), "[DATE: %d/%d/%d] [TIME: %d/%d/%d]: Player %s reported %s(ID:%i) for:\r\n%s\r\n---------------------------------------------------------------------------------------------------------------------\r\n",D,Mo,Y,H,M,S,PlayerName2( playerid ), PlayerName2( params[ 0 ] ), params[ 0 ], params[ 1 ] );
if (file)
{
fwrite(file, STTRR);
fclose(file);
}
return 1;
}