makeAdmin Command urgent
#1

Could I have a makeadmin command that works with rcon AND my enum thing
pawn Код:
if (P_DATA[playerid][pAdmin] < 6) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
Reply
#2

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new admlvl, id, string[128], output[48];
    if (P_DATA[playerid][pAdmin] < 6) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
    if(sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, ERRORCOL, "SYNTAX: /makeadmin [id] [adminlevel]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERRORCOL, "This player is not connected");
    if(admlvl > 6 || admlvl < 0) return SendClientMessage(playerid, ERRORCOL,"Admin levels reach from '0' to '6'");
    {
        switch(admlvl)
        {
            case 1: output = "a Probationary Admin";
            case 2: output = "a General Admin";
            case 3: output = "a Senior Admin";
            case 4: output = "a Server Manager";
            case 5: output = "an Executive Admin";
            case 6: output = "a 'ur rank here'";
            default: output = "an Undefined Admin";
        }
        if(P_DATA[id][pAdmin] != admlvl)
        {
            if(admlvl < P_DATA[id][pAdmin])
            {
                format(string, sizeof(string),"You have been demoted to %s by %s", output ,GetPlayerNameEx(playerid));
            }
            if(admlvl > P_DATA[id][pAdmin])
            {
                format(string, sizeof(string),"You have been promoted to %s by %s", output ,GetPlayerNameEx(playerid));
            }
            if(admlvl == 0)
            {
                format(string, sizeof(string),"You have been fired from the administration team by %s", GetPlayerNameEx(playerid));
            }
            P_DATA[id][pAdmin] = admlvl;
            SendClientMessage(id, 0xFF0000FF, string);
        }
        else SendClientMessage(playerid, 0xFFFFFFFF, "User already has that admin level");
    }
    return 1;
}


stock GetPlayerNameEx(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}
This is the makeadmin in my script, you can edit it how you like. I filled in the P_DATA ect for you.
Reply
#3

cnr.pwn(1335) : warning 202: number of arguments does not match definition
cnr.pwn(1335) : warning 202: number of arguments does not match definition
cnr.pwn(1339) : warning 202: number of arguments does not match definition
cnr.pwn(1339) : warning 202: number of arguments does not match definition
cnr.pwn(1343) : warning 202: number of arguments does not match definition
cnr.pwn(1343) : warning 202: number of arguments does not match definition
cnr.pwn(1316) : warning 204: symbol is assigned a value that is never used: "str"


I dont like warnings,
Reply
#4

Updated it
Reply
#5

cnr.pwn(1336) : warning 202: number of arguments does not match definition
cnr.pwn(1336) : warning 202: number of arguments does not match definition
cnr.pwn(1340) : warning 202: number of arguments does not match definition
cnr.pwn(1340) : warning 202: number of arguments does not match definition
cnr.pwn(1344) : warning 202: number of arguments does not match definition
cnr.pwn(1344) : warning 202: number of arguments does not match definition
Reply
#6

EDIT:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new admlvl, id, string[128], output[48];
    if (P_DATA[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
    if(sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, ERRORCOL, "SYNTAX: /makeadmin [id] [adminlevel]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERRORCOL, "This player is not connected");
    if(admlvl > 6 || admlvl < 0) return SendClientMessage(playerid, ERRORCOL,"Admin levels reach from '0' to '6'");
    {
        switch(admlvl)
        {
            case 1: output = "a Probationary Admin";
            case 2: output = "a General Admin";
            case 3: output = "a Senior Admin";
            case 4: output = "a Server Manager";
            case 5: output = "an Executive Admin";
            case 6: output = "a 'ur rank here'";
            default: output = "an Undefined Admin";
        }
        if(P_DATA[id][pAdmin] != admlvl)
        {
            if(admlvl < P_DATA[id][pAdmin])
            {
                format(string, sizeof(string),"You have been demoted to %s by %s", output ,GetPlayerNameEx(playerid));
            }
            if(admlvl > P_DATA[id][pAdmin])
            {
                format(string, sizeof(string),"You have been promoted to %s by %s", output ,GetPlayerNameEx(playerid));
            }
            if(admlvl == 0)
            {
                format(string, sizeof(string),"You have been fired from the administration team by %s", GetPlayerNameEx(playerid));
            }
            P_DATA[id][pAdmin] = admlvl;
            SendClientMessage(id, 0xFF0000FF, string);
        }
        else SendClientMessage(playerid, 0xFFFFFFFF, "User already has that admin level");
    }
    return 1;
}


stock GetPlayerNameEx(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}
Reply
#7

can u make it so Rcon can use it too?
Reply
#8

Quote:
Originally Posted by Mriss
Посмотреть сообщение
can u make it so Rcon can use it too?
pawn Код:
if (P_DATA[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, ERRORCOL, "You need to be admin to use this command!");
Reply
#9

and error 017: undefined symbol "strreplace"
Reply
#10

Quote:
Originally Posted by Mriss
Посмотреть сообщение
and error 017: undefined symbol "strreplace"
pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)