[Tutorial] Starting off with your admin system
#8

Quote:
Originally Posted by Vince
View Post
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;
}
But I hate scripting like that
Reply


Messages In This Thread
Starting off with your admin system - by FireCat - 02.07.2012, 13:11
Re: Starting off with your admin system - by Spookie98 - 02.07.2012, 13:17
Re: Starting off with your admin system - by FireCat - 02.07.2012, 13:18
Re: Starting off with your admin system - by Spookie98 - 02.07.2012, 13:20
Re: Starting off with your admin system - by StrangeLove - 02.07.2012, 13:21
Re: Starting off with your admin system - by FireCat - 02.07.2012, 13:23
Re: Starting off with your admin system - by Vince - 02.07.2012, 14:34
Re: Starting off with your admin system - by FireCat - 02.07.2012, 15:43
Re: Starting off with your admin system - by Hiddos - 02.07.2012, 18:57
Re: Starting off with your admin system - by FireCat - 02.07.2012, 20:01

Forum Jump:


Users browsing this thread: 3 Guest(s)