SA-MP Forums Archive
makeadmin command for rcon use zcmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: makeadmin command for rcon use zcmd (/showthread.php?tid=446028)



makeadmin command for rcon use zcmd - xganyx - 24.06.2013

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


Re: makeadmin command for rcon use zcmd - [ABK]Antonio - 24.06.2013

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.


Re: makeadmin command for rcon use zcmd - xganyx - 24.06.2013

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


Re: makeadmin command for rcon use zcmd - xMCx - 24.06.2013

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


Re: makeadmin command for rcon use zcmd - xganyx - 24.06.2013

just the same. not work