SA-MP Forums Archive
Help with this command! Please! - 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: Help with this command! Please! (/showthread.php?tid=372458)



Help with this command! Please! - Magic_Time - 26.08.2012

pawn Код:
#define MAX_ADMIN_LEVEL         (7)
#define LEVEL_setadmin              (5)
...................................
........
.....

COMMAND:setadmin(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] == LEVEL_setadmin || IsPlayerAdmin(playerid))
    {
        new player, alevel;
        if(sscanf(params, "rd", player, alevel))
        {
            SendClientMessage(playerid,RED,"Usage: /setadmin <playerid/part of nick> <level>");
            return 1;
        }

        if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID && PlayerInfo[player][Logged] == true)
        {
            if(alevel > MAX_ADMIN_LEVEL)
            {
                SendClientMessage(playerid,RED,"ERROR: Incorrect Level");
                return 1;
            }
            if(alevel == PlayerInfo[player][AdminLevel])
            {
                SendClientMessage(playerid,RED,"ERROR: Player is already this level");
                return 1;
            }
            new year, month, day, hour, minute, second, string[128];
            getdate(year, month, day);
            gettime(hour,minute,second);

            if(alevel > 0)
            {
                format(string,sizeof(string),"Administrator %s has set you to Administrator Status [level %d]",GetName(playerid), alevel);
            }
            else
            {
                format(string,sizeof(string),"Administrator %s has set you to Player Status [level %d]",GetName(playerid), alevel);
            }
            SendClientMessage(player,BLUE,string);

            if(alevel > PlayerInfo[player][AdminLevel])
            {
                GameTextForPlayer(player,"Promoted", 5000, 3);
            }
            else
            {
                GameTextForPlayer(player,"Demoted", 5000, 3);
            }
            format(string,sizeof(string),"You have made %s Level %d on %d/%d/%d at %d:%d:%d", GetName(player), alevel, day, month, year, hour, minute, second);
            SendClientMessage(playerid,BLUE,string);
            format(string,sizeof(string),"Administrator %s has made %s Level %d on %d/%d/%d at %d:%d:%d",GetName(playerid), GetName(player), alevel, day, month, year, hour, minute, second);
            SendClientMessage(player,BLUE,string);
            PlayerInfo[player][AdminLevel] = alevel;
        }
        else
        {
            SendClientMessage(playerid,RED,"ERROR: Cannot assign permissions");
        }
    }
    else
    {
        SendClientMessage(playerid, RED, NO_PERM);
    }
    return 1;
}
The problem is that when I join in game as LEVEL 7, I can't use this command.

IT says "Insuficient Permissions to type this cmd"

Please help me, how I can fix it!


Re: Help with this command! Please! - SuperViper - 26.08.2012

Change

pawn Код:
if(PlayerInfo[playerid][AdminLevel] == LEVEL_setadmin || IsPlayerAdmin(playerid))
to

pawn Код:
if(PlayerInfo[playerid][AdminLevel] >= LEVEL_setadmin || IsPlayerAdmin(playerid))