24.06.2013, 06:55
(
Последний раз редактировалось [ABK]Antonio; 24.06.2013 в 07:30.
)
If you use sscanf...Really easily. I'd recommend using sscanf if you aren't.
So basically, you'd create a new array called 'AdminLevel' outside of this function.
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
That's all it is.
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;
}
pawn Код:
new AdminLevel[MAX_PLAYERS];
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (SomeNumber)
That's all it is.