20.10.2011, 10:29
pawn Code:
CMD:makeadmin(playerid, params[])
{
new victimname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], admlvl, id;
if(PlayerInfo[playerid][pAdmin] >= 10 || IsPlayerAdmin(playerid))
{
if (sscanf(params, "ui", id, admlvl)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setadmin <playerid/name> <level>");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid ID");
if (admlvl > 10 || admlvl < 0) return SendClientMessage(playerid, COLOR_RED,"ERROR: Available Admin Levels: 1-10!");
if(PlayerInfo[id][pAdmin] == admlvl) return SendClientMessage(playerid,COLOR_RED,"ERROR: This player is already this level!");
if(PlayerInfo[id][pAdmin] > admlvl) return GameTextForPlayer(id,"~g~~h~Promoted!",4000,3);
if(PlayerInfo[id][pAdmin] < admlvl) return GameTextForPlayer(id,"~r~~h~Demoted!",4000,3);
PlayerInfo[id][pAdmin] = admlvl;
GetPlayerName(id, victimname, sizeof(victimname));
GetPlayerName(playerid, adminname, sizeof(adminname));
new str[128];
format(str,128,"Administrator %s has set %s Admin Level to %i",adminname,victimname,admlvl);
SendClientMessage(playerid,COLOR_GREEN,str);
format(str, sizeof(str), "Administrator %s has made %s to Admin Level %i",adminname,victimname,admlvl);
SendToAdmins(COLOR_GREY,str);
format(str, sizeof(str), "Administrator %s has made %s to Admin Level %i",adminname,victimname,admlvl);
printf(str);
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You");
return 1;
}