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