Admin Command Error
#1

When im trying my admin command it say "[ADMIN] Your level is not high enough [Level 5]!"
Here is my enum and new
pawn Код:
enum PlayerInfo
{
    Pass[129],
    pLevel,
    pVIP,
    pMoney,
    pScores,
    pKills,
    pDeaths
}
new pInfo[MAX_PLAYERS][PlayerInfo];
The commands :
pawn Код:
CMD:setlevel(playerid,params[])
{
    if(pInfo[playerid][pLevel] >= 5)
    {
        new id, level, n[MAX_PLAYER_NAME], str[128];
        if (sscanf(params, "dd", id, level)) return SendClientMessage(playerid, COLOR_GREEN, "{FF0000}[Set-Level]: {FFFFFF}/setlevel <ID> <Level>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREEN, "{FF0000}[Set-Level]: {FFFFFF}You have entered an incorrect ID");
        GetPlayerName(id, n, MAX_PLAYER_NAME);
        pInfo[playerid][pLevel] = level;
        new INI:file = INI_Open(Path(playerid));
        INI_WriteInt(file,"Level", level);
        INI_Close(file);
        format(str, 128, "[ADMIN] You have set %s's Admin level to %d", n, level);
        SendClientMessage(playerid, COLOR_GREEN, str);
        return 1;
    }
    else return SendClientMessage(playerid,-1,"{FF0000}[ADMIN] Your level is not high enough {FFFFFF}[Level 5]!");
}
Reply
#2

You want to set your level 5 ?
or some one else ?
Reply
#3

Did you store your [pLevel] when player logged in? Like it will read the account files from the person and load his pLevel (just to make sure).

And if I face this problem I usually make a temporary command that shows my current level whether that the script is working or not.
Reply
#4

This thing ?
pawn Код:
INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid);
                SetPlayerScore(playerid,pInfo[playerid][pScores]);
                GivePlayerMoney(playerid,pInfo[playerid][pMoney]);
                INI_Int("AdminLevel",pInfo[playerid][pLevel]);
                INI_Int("VIP",pInfo[playerid][pVIP]);
                INI_Int("Kills",pInfo[playerid][pKills]);
                INI_Int("Deaths",pInfo[playerid][pDeaths]);
                ShowPlayerDialog(playerid, DIALOG_ACCES, DIALOG_STYLE_MSGBOX, "Account Acces", "Welcome Back, You've been succesfully loginned !", "Register", "Quit");
Reply
#5

can someone help ?
Reply
#6

Is it loading correctly? You should use printf's at the login part and check the console.

EDIT: Just saw the mistake:
pawn Код:
//setlevel:
INI_WriteInt(file,"Level", level);

//login part:
INI_Int("AdminLevel",pInfo[playerid][pLevel]);
So change "Level" to "AdminLevel"
Reply
#7

Well,you're using "if(pInfo[playerid][pLevel] >= 5)"
It should be AdminLevel instead...Try that.


EDIT: Mhm....Set your LEVEL = 6,then try this Command
Reply
#8

If you don't have level 5 or above it won't work.

Also you don't need

pawn Код:
new INI:file = INI_Open(Path(playerid));
        INI_WriteInt(file,"Level", level);
        INI_Close(file);
Reply
#9

pawn Код:
CMD:setlevel(playerid,params[])
{
    if(pInfo[playerid][pLevel] > 5)
    {
        new id, level, n[MAX_PLAYER_NAME], str[128];
        if (sscanf(params, "dd", id, level)) return SendClientMessage(playerid, COLOR_GREEN, "{FF0000}[Set-Level]: {FFFFFF}/setlevel <ID> <Level>");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_GREEN, "{FF0000}[Set-Level]: {FFFFFF}You have entered an incorrect ID");
        GetPlayerName(id, n, MAX_PLAYER_NAME);
        pInfo[ID][pLevel] = level; //Why do you use playerid here? It should be ID.
        format(str, 128, "[ADMIN] You have set %s's Admin level to %d", n, level);
        SendClientMessage(playerid, COLOR_GREEN, str);
        return 1;
    }
    else return SendClientMessage(playerid,-1,"{FF0000}[ADMIN] Your level is not high enough {FFFFFF}[Level 5]!");
}
Reply
#10

Still Error
Here my player data
Код:
Level = 5
VIP = 5
[Player's Data]
Level = 0
VIP = 0
Money = 0
Scores = 0
Kills = 0
Deaths = 0
and
pawn Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Password", pInfo[playerid][Pass],129);
    INI_Int("Level",pInfo[playerid][pLevel]);
    INI_Int("VIP",pInfo[playerid][pVIP]);
    INI_Int("Money",pInfo[playerid][pMoney]);
    INI_Int("Scores",pInfo[playerid][pScores]);
    INI_Int("Kills",pInfo[playerid][pKills]);
    INI_Int("Deaths",pInfo[playerid][pDeaths]);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)