24.09.2016, 05:01
Код:
stock IsAdmin(playerid, level) { if(pInfo[playerid][Admin] >= level) return 1; if(IsPlayerAdmin(playerid)) return 1; return 0; } stock GetAdminRank(rank) { new lvlname[30]; switch(rank) { case 0: lvlname = "Not Admin"; case 1: lvlname = "Moderator"; case 2: lvlname = "Junior Administrator"; case 3: lvlname = "Senior Administrator"; case 4: lvlname = "Executive Administrator"; case 5: lvlname = "Owner"; } return lvlname; } CMD:makeadmin(playerid, params[]) { if(!IsAdmin(playerid, 5))return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not a high enough level to use this command."); new ID; new lvl; new string[128]; if(sscanf(params, "ud", ID, lvl))return SendClientMessage(playerid, COLOR_RED, "USAGE: /makeadmin [PlayerID/Name] [Level]"); if(!IsPlayerConnected(ID))return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected. Use /adminoffline to set an offline player's level."); if(pInfo[ID][Admin] == lvl)return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is already that level."); if(pInfo[ID][Admin] < lvl)format(string, sizeof(string), "~g~Promoted to~n~~w~Admin Level %d", lvl); if(pInfo[ID][Admin] > lvl)format(string, sizeof(string), "~r~Demoted to~n~~w~Admin Level %d", lvl); GameTextForPlayer(playerid, string, 9000, 0); pInfo[ID][Admin] = lvl; format(string, sizeof(string), "-| You have given %s(%d) admin level %d (%s) |-", GetName(ID), ID, lvl, GetAdminRank(lvl)); SendClientMessage(playerid, COLOR_ADMIN, string); format(string, sizeof(string), "-| Admin %s has given you admin level %d (%s) |-", GetName(playerid), lvl, GetAdminRank(lvl)); SendClientMessage(ID, COLOR_ADMIN, string); return 1; }