[ZCMD]Admin command
#1

Hello mates,

I got another issue, When I type an admin command it says I'm not allowed to use that command but I'm admin, on my .ini file it says I'm admin level 4 but I can't use a command for admin level 3? Wtf

I tried everything but nothing works

Note: I just switched the command processor, so I'm kinda newbie with ZCMD :P

pawn Code:
CMD:setwanted(playerid,params[])
{
    new ID;
    new Wantedl;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    if(sscanf(params, "ui", ID,Wantedl)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}Usage: /setwanted <playerid> <wantedlevel>");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1,"{FF0000}__**ERROR**__ {FFFFFF}That player is not connected to the server!");
    SetPlayerWantedLevel(ID,Wantedl);
    return 1;
}
pawn Code:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pWantedLevel,
    pScore,
    pBankCash,
    pBankAccount,
    pRobSkill
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#2

pawn Code:
CMD:setwanted(playerid,params[])
{
    new ID;
    new Wantedl;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    if(PlayerInfo[playerid][pAdmin] >= 3) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    if(sscanf(params, "ui", ID,Wantedl)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}Usage: /setwanted <playerid> <wantedlevel>");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1,"{FF0000}__**ERROR**__ {FFFFFF}That player is not connected to the server!");
    SetPlayerWantedLevel(ID,Wantedl);
    return 1;
}
Reply
#3

Try this, I have two script for you, you can choose anything that suits you.

pawn Code:
CMD:setwanted(playerid,params[])
{
    new ID, Wantedl;
    if(PlayerInfo[playerid][pAdmin] >= 3 || IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    {
        if(sscanf(params, "ui", ID, Wantedl)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}Usage: /setwanted <playerid> <wantedlevel>");
        if(!IsPlayerConnected(ID) || ID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1,"{FF0000}__**ERROR**__ {FFFFFF}That player is not connected to the server!");
        SetPlayerWantedLevel(ID, Wantedl);
    }
    else
    {
        SendClientMessage(playerid, -1, "{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    }
    return 1;
}
In your version:

pawn Code:
CMD:setwanted(playerid,params[])
{
    new ID;
    new Wantedl;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
    if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");// Admins below level 3 will not allow to use this command but level 3 and higher are able to use this command
    if(sscanf(params, "ui", ID, Wantedl)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}Usage: /setwanted <playerid> <wantedlevel>");
    if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1,"{FF0000}__**ERROR**__ {FFFFFF}That player is not connected to the server!");
    SetPlayerWantedLevel(ID, Wantedl);
    return 1;
}
Reply
#4

Quote:
Originally Posted by Lynn
View Post
pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 3) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
Wrong.

pawn Code:
if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
Right.
==========================================
And remove:
pawn Code:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"{FF0000}__**ERROR**__ {FFFFFF}You cannot use this command");
The admin rank check already does the job for this. It's not really necessary..
Reply
#5

It is easier to create an external stock to check if a player is at a specific admin level, if yes then,
the stock will return 1, otherwise it will return 0, it is much easier then using the admin checking method,
in each and each command.

"IsPlayerAdmin" - Is used to check if the player is logged in into RCON or not!
Reply
#6

Quote:
Originally Posted by Franx
View Post
It is easier to create an external stock to check if a player is at a specific admin level, if yes then,
the stock will return 1, otherwise it will return 0, it is much easier then using the admin checking method,
in each and each command.

"IsPlayerAdmin" - Is used to check if the player is logged in into RCON or not!
Not necessarily easier, it saves time, but just putting the "is greater than, is equal to, etc." it makes the commands more complex and easier to set for rank. I understand what you mean about making a stock to check if it's a specific level though. I may do that myself now that you mentioned it :\

And the IsPlayerAdmin, exactly as I said... It's not needed in that piece of code...
Reply
#7

Thanks for all the help guys, I fixed it
+rep for you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)