makeadmin command for rcon use zcmd
#1

how do i do /makeadmin command for rcon and the command use zcmd ?
Reply
#2

If you use sscanf...Really easily. I'd recommend using sscanf if you aren't.

pawn Код:
CMD:makeadmin(playerid, params[])
{
    //a check to make sure they're the level you want
    if(!IsPlayerAdmin(playerid) && AdminLevel[playerid] < 3) return SendClientMessage(playerid, 0xCC0000AA, "You aren't the required level!");

    //variables we need to do this
    new target, level;

    //r = player name or id, i = integer
    if(sscanf(params, "ri", target, level)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /makeadmin [player] [level]");

    //check to make sure they aren't setting a higher level admins level
    if(AdminLevel[target] >= AdminLevel[playerid]) return SendClientMessage(playerid, 0xCC0000AA, "That player is a higher level admin or the same level admin as you!");

    //a string array so we can format the message with variables along with an array to store the players name in
    new string[128], name[MAX_PLAYER_NAME];

    //Here we set the players level
    AdminLevel[target] = level;
   
    //get the name of the admin, format the string, then send the string here
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has set your level to %i", name, level);
    SendClientMessage(target, 0x00CCCCAA, string);

    //same as above but this time for the admin that set the players level
    GetPlayerName(target, name, sizeof(name));
    format(string, sizeof(string), "You set the admin level of %s to %i", name, level);
    SendClientMessage(playerid, 0x00CCCCAA, string);
    return 1;
}
So basically, you'd create a new array called 'AdminLevel' outside of this function.
pawn Код:
new AdminLevel[MAX_PLAYERS];
This creates the array with the size of your MAX_PLAYERS define. MAX_PLAYERS is defined in the a_samp include. You can change it in the script with
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (SomeNumber)

That's all it is.
Reply
#3

But when i'm type /makeadmin 2 3
it just said : USAGE : /makeadmin [playerid] [level]
Reply
#4

change this :if(sscanf(params, "ri", target, level)) to
if(sscanf(params, "ui", target, level))
Reply
#5

just the same. not work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)