02.07.2012, 14:34
Spacing helps, you know. I don't quite like code where everything is crammed together. The compiler ignores whitespace anyway. I'd rather space it out like this:
pawn Code:
CMD:setlevel(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, -4, "Only rcon admins can set admin levels!"); //Checking if the player is rcon admin to set an admin level
new
id,
level; //Creating the id variable to store the selected id and a level variable for the chosen admin level.
if(sscanf(params, "ui", id, level))
return SendClientMessage(playerid, -1, "USAGE: /setlevel <id> <level>");//Check if the player inputted a username or id and a admin level.
if(!IsPlayerConnected(id))
return SendClientMessage(playerid, -4, "That player is not connected!"); //Checking if the selected user is connected or not.
new
file[64],
PlayerName[24]; //Creating a variable to store the file path, and a variable to store the players name.
GetPlayerName(id, PlayerName, sizeof PlayerName); //Retrieving the selected id's name,
format(file, sizeof file, "Admin/%s.ini", PlayerName);
if(!fexist(file))
return SendClientMessage(playerid, -4, "That player is not registered"); //Checking if the player is not registered
INI_Open(file); //Opening the file with SII include
INI_WriteInt("Level", level); //Writing the line "Level" the selected admin level.
INI_Save(); //Saving the file
INI_Close(); //Closing the file
PInfo[id][Level] = level;
SendClientMessage(playerid, -1, "You have changed the selected user's admin level");
SendClientMessage(id, -1, "Your admin level has been changed");
return 1;
}