SA-MP Forums Archive
Set a player's admin level in game. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Set a player's admin level in game. (/showthread.php?tid=596006)



Set a player's admin level in game. - Sebz - 11.12.2015

This is basically how the system is set up, it saves these values to a .ini for each player. Up until now, I have had to manually enter a value into the .ini file to set an admin level. I'd like to be able to do it VIA a cmd in game.

enum PlayerInfo
{
Pass[129], //User's password
Adminlevel, //User's admin level
VIPlevel, //User's vip level
Money, //User's money
Scores, //User's scores
Kills, //User's kills
Deaths //User's deaths
}
new pInfo[MAX_PLAYERS][PlayerInfo]; /*This will create a new variable so we can later use it to saving/loading user's info.*/

All I want to know is how to /setlevel a player in game. I use izcmd.

So, for example, if I were to do "/setlevel NAME/ID 3", it would set the player's Adminlevel to 3.

Thanks ahead of time for your assistance!


Re: Set a player's admin level in game. - thefirestate - 11.12.2015

The most simple way:

PHP код:
CMD:makeadmin(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] == 5// I am asuming you have 5 different admin levels, not sure how exactly you have.
    
{
         new 
toidlevel;
         if(!
sscanf(params"ui"toidlevel))
         {
             
pInfo[toid][Adminlevel] = level;
             new 
string[50];
             
format(stringsizeof(string), "You have been set as level %d administrator."level);
             
SendClientMessage(toid, -1string);
             new 
name[25];
             
GetPlayerName(toidnamesizeof(name));
             
format(stringsizeof(string), "You have set %s's admin level to %d."namelevel);
        }
        else return 
SendClientMessage(playerid, -1"USAGE: /makeadmin [playerid/partofname] [level]");
    }
    else return 
SendClientMessage(playerid, -1"Access denied.");

If you have any questions, ask.


Re: Set a player's admin level in game. - Sjn - 11.12.2015

Quote:
Originally Posted by thefirestate
Посмотреть сообщение
The most simple way:

PHP код:
CMD:makeadmin(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || pInfo[playerid][Adminlevel] == 5// I am asuming you have 5 different admin levels, not sure how exactly you have.
    
{
         new 
toidlevel;
         if(!
sscanf(params"ui"toidlevel))
         {
             
pInfo[toid][Adminlevel] = level;
             new 
string[50];
             
format(stringsizeof(string), "You have been set as level %d administrator."level);
             
SendClientMessage(toid, -1string);
             new 
name[25];
             
GetPlayerName(toidnamesizeof(name));
             
format(stringsizeof(string), "You have set %s's admin level to %d."namelevel);
        }
        else return 
SendClientMessage(playerid, -1"USAGE: /makeadmin [playerid/partofname] [level]");
    }
    else return 
SendClientMessage(playerid, -1"Access denied.");

If you have any questions, ask.
Well, you do realize he said he want to save the player's admin level in a file, right? With your code, it only sets player's level temporarily in-game which gets cleared after player disconnects.

OP: Which file reading/writing system are you using?


Re: Set a player's admin level in game. - xTURBOx - 11.12.2015

i think he is using Y_INI.
If you dont save data onplayerdisconnect, like Sjn said, it will set player's level temporarily in-game which gets cleared after player disconnects.


Re: Set a player's admin level in game. - Sebz - 11.12.2015

Oh, of course it saves on disconnect.

Question answered, thank you everyone.