Help with Y_INI
#1

Hello, i want to save admins with Y_INI.

Code:

CMD:giveadmin(playerid, params[]){
new id, lvl;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "blablabla ");
if(sscanf(params, "ud", id, nivel)) return SendClientMessage(playerid, -1, "Use blablabla");
PlayerInfo[id][pAdmin] = lvl;
return true;
}
Reply
#2

You have got the wrong codes. too much errors on that, use mine.


Код:
CMD:setlevel(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] < 4) return SendClientMessage(playerid, COLOR_WHITE, "You are not allowed to use this command.");
    new id,level, name[MAX_PLAYER_NAME+4], string[148];
    GetPlayerName(id, name, sizeof(name));
       if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /setlevel [playerid] [level 0-5]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Player not connected.");
    if(level > 5) return SendClientMessage(playerid,COLOR_LIGHTGREEN,"Error! You can only pick between level 0-5 (0: Player - 1: Moderator - 2: Junior - 3: Administrator - 4: Senior - 5: Owner)");
    if(PlayerInfo[playerid][pAdminLevel] < level)
    {
        PlayerInfo[playerid][pAdminLevel] = level;
        format(string, sizeof(string), "You have been promoted to %d level succesfully.", level);
        SendClientMessage(id,COLOR_LIGHTGREEN, string);
        format(string, sizeof(string), "You have promoted %s succesfully to level %d.", name, level);
        SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
    }
        else
        {
        PlayerInfo[playerid][pAdminLevel] = level;
        format(string, sizeof(string), "You have been demoted to %d level.", level);
        SendClientMessage(id, COLOR_WHITE, string);
        format(string, sizeof(string), "You have demoted %s succesfully to level %d.", name, level);
        SendClientMessage(playerid, COLOR_CRIMSON, string);
    }
    return 1;
}
Note that dont forget to define the COLORS texts. I forgot the codes, you might wanna use ****** for it.
Reply
#3

but how to set me admin? i want to do this command using rcon.

Sorry to my english '-'
Reply
#4

Have you got saving system ? , show me your enums if you have.
pawn Код:
enum pInfo{
   pAdmin,
   blablabla};
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#5

enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}

and

new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#6

Quote:
Originally Posted by Jogg1
Посмотреть сообщение
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}

and

new PlayerInfo[MAX_PLAYERS][pInfo];
You did that right , if you have saving stats it will save the admin variable after disconnecting.
pawn Код:
CMD:giveadmin(playerid, params[])
{
    new id, lvl;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "blablabla ");
    if(sscanf(params, "ud", id, lvl)) return SendClientMessage(playerid, -1, "Use blablabla");//here was just a mistake because you wrote sscanf by wrong. d means integer , and you wrote 'nivel' instead of 'lvl'
    PlayerInfo[id][pAdmin] = lvl;
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)