Admin and Mod restriction
#1

Hey, how do I make this code able to work with Admin and Mod only? I know I can do ''if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pMod] == 1)'' but that won't work, because I also need to be set as mod then, how can I do this in a way which works?



pawn Код:
YCMD:unjail(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");

    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(PlayerInfo[playerid][pAjailed] == 1)
        {
            new id, string[256];
            if(sscanf(params, "u", id)) return SCM(playerid, COLOR_GRAD, "USAGE: /unjail [playerid]");
            PlayerInfo[id][pAjailTime] = 0;
            PlayerInfo[id][pAjailed] = 0;
            PlayerInfo[id][pPrisons]-= 1;
            SetPlayerInterior(id, 0);
            SetPlayerVirtualWorld(id, 0);
            SetPlayerPos(id, 448.9938,-1663.6447,25.5938);
            TextDrawHideForPlayer(id, Textdraw6969[id]);
            format(string, sizeof(string),"[INFO]: Admin %s has unjailed %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
            ABroadCast(COLOR_ORANGE,string, 5);
            format(string, sizeof(string), "You have unjailed %s.",GetPlayerNameEx(id));
            SCM(playerid, COLOR_BLUE, string);
            format(string, sizeof(string), "Admin %s has unjailed you.",GetPlayerNameEx(playerid));
            SCM(id, COLOR_BLUE, string);
        }
        else
        {
            new string[128];
            format(string,sizeof(string),"This player is not in Ajail.");
            SCM(playerid, COLOR_GRAD1, string);
        }
    }
    else
    {
        new string[128];
        format(string,sizeof(string),"~n~~n~~w~You cannot use this command.");
        TextDrawSetString(Textdraw69[playerid],string);
        TextDrawShowForPlayer(playerid, Textdraw69[playerid]);
        SetTimer("hidetextdraw", 4000, false);
    }
    return 1;
}
Reply
#2

I don't really understand what you're trying to say.. However I attempted to do what i 'think' you want

pawn Код:
YCMD:unjail(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");

    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(PlayerInfo[playerid][pMod] < 1) return SCM(playerid, COLOR_GREY, "You're not a moderator..");
        {//I added the line above
            if(PlayerInfo[playerid][pAjailed] == 1)
            {
                new id, string[256];
                if(sscanf(params, "u", id)) return SCM(playerid, COLOR_GRAD, "USAGE: /unjail [playerid]");
                PlayerInfo[id][pAjailTime] = 0;
                PlayerInfo[id][pAjailed] = 0;
                PlayerInfo[id][pPrisons]-= 1;
                SetPlayerInterior(id, 0);
                SetPlayerVirtualWorld(id, 0);
                SetPlayerPos(id, 448.9938,-1663.6447,25.5938);
                TextDrawHideForPlayer(id, Textdraw6969[id]);
                format(string, sizeof(string),"[INFO]: Admin %s has unjailed %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(id));
                ABroadCast(COLOR_ORANGE,string, 5);
                format(string, sizeof(string), "You have unjailed %s.",GetPlayerNameEx(id));
                SCM(playerid, COLOR_BLUE, string);
                format(string, sizeof(string), "Admin %s has unjailed you.",GetPlayerNameEx(playerid));
                SCM(id, COLOR_BLUE, string);
            }
            else
            {
                new string[128];
                format(string,sizeof(string),"This player is not in Ajail.");
                SCM(playerid, COLOR_GRAD1, string);
            }
        }
        else
        {
            new string[128];
            format(string,sizeof(string),"~n~~n~~w~You cannot use this command.");
            TextDrawSetString(Textdraw69[playerid],string);
            TextDrawShowForPlayer(playerid, Textdraw69[playerid]);
            SetTimer("hidetextdraw", 4000, false);
        }
        return 1;
}
Try something like that, it requires you to be a moderator and an administrator to preform the command.
Reply
#3

I hope that's right, can't test it right now. What I tried to say.

I got a Admin system and Mod system

Admin : pAdmin == 1-6, pMod == 0.
Mod : pAdmin == 0, pMod == 1.

When I have: if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pMod] == 1)

It will always say I can't use the command because I'm not set as pMod, or a Mod is not set as pAdmin, you understand now I hope! .


Getting 26 errors with the line u added btw.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)