/makeadmin Command
#1

Alright so i've just started this gamemode from scratch and such, and i'm working on the admin system currently. So i've just done the /makeadmin command and whenever you use it in game "level" returns and empty value and doesn't set the admin level.

The code is using zcmd and SSCANF2.
The file saving is y_ini.


The code:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new id,level;
    if(PlayerInfo[playerid][pAdmin] > 5)
    {
        if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [ID] [Adminlevel]");
        {
            if(level > 100000) return SendClientMessage(playerid, ORANGE, "Invalid Level. Valid levels are 1,2,3,4,1336,1337,100000");
            else
            {
                PlayerInfo[id][pAdmin] = level;
                format(cmdstr, sizeof(cmdstr), "You've been promoted to a level %d Administrator");
                SendClientMessage(id, ORANGE, cmdstr);
                return 1;
            }
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "You're not authorized to give admin levels sir!");
        return 1;
    }
}
Reply
#2

Try this:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new id,level, cmdstr[90];
    if(PlayerInfo[playerid][pAdmin] > 5)
    {
        if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [ID] [Adminlevel]");
        {
            if(level > 100000) return SendClientMessage(playerid, ORANGE, "Invalid Level. Valid levels are 1,2,3,4,1336,1337,100000");
            else
            {
                PlayerInfo[id][pAdmin] = level;
                format(cmdstr, sizeof(cmdstr), "You've been promoted to a level %d Administrator");
                SendClientMessage(id, ORANGE, cmdstr);
                return 1;
            }
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "You're not authorized to give admin levels sir!");
    }
    return 1;
}
Reply
#3

0000
Reply
#4

public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[256],str[256],Name[MAX_PLAYER_NAME];
if(!strcmp("/makeadmin",cmdtext,true))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid,-1,"/makeadmin (id) (level)");
new id = strval(tmp);
if(id==playerid)return SendClientMessage(playerid,-1,"Invalid playerid");
if(IsPlayerConnected(id))return SendClientMessage(playerid,-1,"This player isn't connected");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid,-1,"/makeadmin (id) (level)");
new level = strval(tmp);
if(level<0 || level >4)return SendClientMessage(playerid,-1,"! ! ! ! !");
GetPlayerName(playerid,Name,sizeof(Name));
format(str,sizeof(str),"You have nomited an admin level %d by %s",level,Name);
SendClientMessage(id,-1,str);
PlayerInfo[id][AdminLevel]=level;
return 1;
}
return 0;

}
Reply


Forum Jump:


Users browsing this thread: