How to put Limit in this?
#21

Please help me read above.
Reply
#22

Quote:
Originally Posted by Harry_Sandhu
View Post
There is Still a Problem in this Code.
I have put
pawn Code:
if(IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdmin] >= 5)
But when i am lvl5 also then it also says you are not authorized.
And when i RCon log then it worx but if i am less than lvl 5 then on Rcon also it wont Work. plZ HELP
pawn Code:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 5)
When u put && it will work ONLY if you are RCON and lvl5 admin. This way it will work if you are RCON or lvl5 (&& means AND, || means OR)
Reply
#23

pawn Code:
CMD:makeadmin(playerid, params[])
{
                                                  //24 is max player  name
    new playerid2,level,aName[24],pName2[24],string[128];
    if(PlayerInfo[playerid][pAdmin] > 4 || IsPlayerAdmin(playerid))
    {
        if(sscanf(params,"ud",playerid2,level)) return SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
        if(!IsPlayerConnected(playerid2)) return SendClientMessage(playerid,ERROR,"Invalid Player.");
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerid2][pAdmin]) return SendClientMessage(playerid, ERROR,"You cannot promote/demote a Higher rank admin than you.");
        if(level >= 0 && level < 7)
        {
            GetPlayerName(playerid, aName,24);
            GetPlayerName(playerid2, pName2,24);

            format(string,sizeof(string), "Admin %s gave you Admin level %d",aName,level);
            SendClientMessage(playerid2, COLOR_YELLOW, string);

            format(string,sizeof(string), "You gave Admin level %d to %s",level,pName2);
            SendClientMessage(playerid, ADMIN, string);

            format(string, sizeof(string),"Admin %s gave admin level %d to %s",aName,level,pName2);
            SendAdminMessage(COLOR_RED, string);

            PlayerInfo[playerid2][pAdmin] = level;
            return 1;
        }
        else
            SendClientMessage(playerid, ERROR,"Usage: /makeadmin [Playerid/PartOfName][Level(0-6)]");
    }
    else
        SendClientMessage(playerid, ERROR, "You are not authorized to use that command.");
    return 1;
}
That should work.

EDITED first version was bugged.. couldn't set level to 0. Fixed now.

Ps, don't forget if your server is R5 then the 'u' (sscanf) parameter won't work ATM.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)