ZCMD Makeadmin
#1

So I figured somehow out this code:
pawn Код:
COMMAND:makeadmin(playerid, params[])
    {
            tmp = strtok(params, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "[USAGE:] /makeadmin [playerid] [adminlevel]");
                return 1;
            }
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(params, idx);
            level = strval(tmp);
            if (PlayerInfo[playerid][pAdminLevel] >= 5 || IsPlayerAdmin(playerid))
            {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        PlayerInfo[para1][pAdminLevel] = level;
                        new name[MAX_PLAYER_NAME];
                        GetPlayerName(playerid, name, sizeof(name));
                        new string[128];
                        format(string, sizeof(string), "[INFO:] %s has just made you administrator level: %d.", name,level);
                        SendClientMessage(para1, COLOR_WHITE, string);
                        format(string, sizeof(string), "[INFO:] You have made %s an administrator - Level: %d.", name,level);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                    }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "[ERROR:] Your not an administrator/correct level.");
            }
        return 1;
    }
Now I know where the problem itself SHOULD be:
pawn Код:
tmp = strtok(params, idx);
What should i replace params with? Using zcmd and sscanf. By the way if I do /makeadmin it keeps telling me the form how to do it.
Reply
#2

easy peasy, needs to be edited according to your system.
pawn Код:
CMD:setadmin(playerid, params[])
{
    new victimname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], admlvl, id;
    if (PlayerInfo[playerid][pAdminLevel] >= MAX_ADMIN_LEVEL)
    {
        if (sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: /setadmin [id] [adminlevel]");
        if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAY, "AdmCmd: This player is not connected");
        if (admlvl > MAX_ADMIN_LEVEL || admlvl < 0) return SendClientMessage(playerid, COLOR_GRAY,"Don't go below 0 or over max admin level!");
        PlayerInfo[id][pAdminLevel] = admlvl;
        GetPlayerName(id, victimname, sizeof(victimname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        new str[128];
        format(str,128,"AdmWarn: %s [ID %d] has set %s [ID %d] admin level to %i",adminname, playerid, victimname, id, admlvl);
        SendAdminMessage(COLOR_LIGHTRED,str);
        return 1;
    }
    else return SendClientMessage(playerid,COLOR_GRAY,"  You don't have authorization!");
}
Reply
#3

Yes, I already actually figured it out myself and fixed it. Thanks anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)