CMD:makeadmin(playerid, params[]) { if(IsPlayerAdmin(playerid)) { new id, level, string[126]; if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COL_SYSTEM, "* Syntax: /makeadmin "COLOR_ORANGE"[TargetID] [Level 1-1336]"COLOR_SYSTEM" *"); PlayerInfo[id][pAdmin] = level; format (string, sizeof(string), "* System: "COLOR_ORANGE"[Administrator] - %s"COLOR_SYSTEM" has set your admin level to "COLOR_ORANGE"%d"COLOR_SYSTEM". *", GetNameEx(playerid), level); SendClientMessage(id, COL_SYSTEM, string); format (string, sizeof(string), "* System: You have set "COLOR_ORANGE"%s's"COLOR_SYSTEM" admin level to "COLOR_ORANGE"%d"COLOR_SYSTEM". *", GetNameEx(id), level); SendClientMessage(playerid, COL_SYSTEM, string); } else { SendClientMessage(playerid, COL_SYSTEM, "* System: You are "COLOR_LIGHTRED"not allowed"COLOR_SYSTEM" to use this command! *"); } return 1; }
static const LVLNames[][] =
{
"junior", "junior", "name for level 2", "name for level 3",
};
cmd:level(playerid, params[])
{
new str[20];
format(str, sizeof(str), "You are: %s", LVLNames[playerlevel]);
SendClientMessage(playerid, -1, str); //levels 0-1 junior rest you decide.
return 1;
}
Use an array or a switch. Also perhaps this is just me, but I think admin levels like 1337 or 9999 are super retarded. You need at most 5 or so.
|
You can either do a conditional checking based on level variable and initialize a string according to it and display it. Or you can have constant global or static array of strings having nominal meaning of each level so as to use these level variable as indices to access this array contents.
|
I am not really familiar with those..can you make a small example for me please? :O
|
stock ReturnAdminRank(rankid) { new string[20]; switch(rankid){ case 1: string = "Game Admin I"; case 2: string = "Game Admin II"; case 3: string = "Game Admin III"; case 4: string = "Lead Admin I"; case 5: string = "Lead Admin II"; case 6: string = "Co-Owner"; case 7: string = "Owner"; } return string; }