[dcmd] setlevel dosen't work
#1

i need help with this dcmd code D:

it compiles right but it says you need to be admin lvl 10 when i am lvl 10 O.o

if someone can fix this it would be very helpful!
pawn Код:
dcmd_setlevel(playerid, params[])
{
    new
    id,
    lvl;
    if (sscanf(params, "uc", id, lvl)) SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel playerid level");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    if(lvl >= 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!");
    else
    {
        if(PlayerInfo[playerid][AdminLevel] >= 10) return 0;
        PlayerInfo[playerid][AdminLevel] = lvl;
        new name[MAX_PLAYER_NAME], string2[44];
        GetPlayerName(playerid, name, sizeof(name));
        format(string2, sizeof(string2), "You have set player %s to AdminLevel %s",name,lvl);
        SendClientMessage(playerid,0xFF0000AA,string2);

    }
    return 1;
}
Reply
#2

Because what you type in (/setlevel [id] [for example: 3]), that has been sscanfed into the lvl variable (sscanf(params,"ui",id,lvl)) and after that you check the lvl variable. (lvl >= 10), but it's not 10, it's 3. So that is the problem.
Reply
#3

pawn Код:
dcmd_setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!");
    {
        new targetid, level;
        if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel [playerid | name] [level]");
        else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        {
            new targetname[MAX_PLAYER_NAME], string[44];
            GetPlayerName(targetid, targetname, sizeof(targetname));
            PlayerInfo[targetid][AdminLevel] = level;
            format(string, sizeof(string), "You have set player %s to AdminLevel %s", targetname, level);
            SendClientMessage(playerid, 0xFF0000AA, string);
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by CyberGhost
Посмотреть сообщение
pawn Код:
dcmd_setlevel(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, 0xFF0000AA, "You must be administrator level 10 to use that command!");
    {
        new targetid, level;
        if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setlevel [playerid | name] [level]");
        else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
        {
            new targetname[MAX_PLAYER_NAME], string[44];
            GetPlayerName(targetid, targetname, sizeof(targetname));
            PlayerInfo[targetid][AdminLevel] = level;
            format(string, sizeof(string), "You have set player %s to AdminLevel %s", targetname, level);
            SendClientMessage(playerid, 0xFF0000AA, string);
        }
    }
    return 1;
}
thanks! works perfectly!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)