Admin promoting :P
#1

So, here's the deal.

In all the enums and defines etc., I have Admin and pAdmin set. However, I have this command:

Код:
CMD:promote(playerid,params[])
{
	new id,level;
    if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
    {
        if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Koristi: /promote [ID] [LVL]");
        else
        {
            if(level > 5) return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Ne smijete ici iznad 5!");
            else
            {
                new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
                INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
                INI_Close(File); //closes the ini file
                SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Promovirali ste igraca u server administratora");
            }
        }
    }
    return 1;
}
And I'm having a problem with this line:

INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.

Because in the user file in Scriptfiles, I already have Admin:, and when I use /promote on someone, it doesn't write the new level in that line, it rather creates a new line at the top of the scriptfile, and the Admin below is empty. And then, when I use admin-related commands, they respond with "You're not an admin"
Reply
#2

pawn Код:
INI_SetTag(INI:file, tag[]);
Use that when you're writing to it.

pawn Код:
new INI:File = INI_Open(UserPath(id))
INI_SetTag(File,"Some tag");
INI_WriteInt(File,"Admin",level);
INI_Close(File);
Not used Y_Ini in a while so it may not be 100% accurate.

Or since you're going to be saving data right?

Why not do:

pawn Код:
pInfo[id][pAdmin] = level;
That way it'll save when you call the saving function (provided you've got a callback to handle data saving on money/stat/death/kill changes.
Reply
#3

Thanks!
Reply
#4

Just one more question :S How do I make the player get the message "You have been promoted to a lvl admin?"
Reply
#5

Quote:
Originally Posted by Strummer
Посмотреть сообщение
Just one more question :S How do I make the player get the message "You have been promoted to a lvl admin?"
pawn Код:
CMD:promote(playerid,params[])
{
    new id,level;
    if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
    {
        if(sscanf(params,"ud",id,level))return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Koristi: /promote [ID] [LVL]");
        else
        {
            if(level > 5) return SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Ne smijete ici iznad 5!");
            else
            {
                new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
                INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
                INI_Close(File); //closes the ini file
                SendClientMessage(playerid, -1,""COL_LIGHTBLUE"Promovirali ste igraca u server administratora");
//Just add this part to your cmd!
                new string[128];
                format(string,sizeof(string),"You have been promoted to level %d admin",level);
                SendClientMessage(id,-1,string);
/////
            }
        }
    }
    return 1;
}
Reply
#6

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)