02.01.2016, 13:48
PHP код:
CMD:setadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new targetplayer, string[150], Level;
if(sscanf(params, "ui", targetplayer, Level)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /setadmin [ID] [Level 1-5]");
if(Level < 1 || Level > 5) return SendClientMessage(playerid, COLOR_RED, "Error: Available admin levels [1 - 5]");
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Error: Player is not connected!");
if(PlayerInfo[targetplayer][AdminLevel] == Level) return SendClientMessage(playerid, COLOR_RED, "Error: The player is already this admin level.");
new INI:File = INI_Open(UserPath(targetplayer));
INI_WriteInt(File, "Admin", Level);
INI_Close(File);
if(Level == 1)
{
format(string, sizeof string, "You have been set to a Trial Moderator by %s.", PlayerName(playerid));
SendClientMessage(targetplayer, COLOR_LIGHTBLUE, string);
format(string, sizeof string, "You have set %s as a Trial Moderator.", PlayerName(targetplayer));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
if(Level == 2)
{
format(string, sizeof string, "You have been set to a Moderator by %s.", PlayerName(playerid));
SendClientMessage(targetplayer, COLOR_YELLOW, string);
format(string, sizeof string, "You have set %s as a Moderator.", PlayerName(targetplayer));
SendClientMessage(playerid, COLOR_YELLOW, string);
}
if(Level == 3)
{
format(string, sizeof string, "You have been set to a General Administrator by %s.", PlayerName(playerid));
SendClientMessage(targetplayer, COLOR_GREEN, string);
format(string, sizeof string, "You have set %s as a General Administrator.", PlayerName(targetplayer));
SendClientMessage(playerid, COLOR_GREEN, string);
}
if(Level == 4)
{
format(string, sizeof string, "You have been set to a Co-Owner by %s.", PlayerName(playerid));
SendClientMessage(targetplayer, COLOR_ORANGE, string);
format(string, sizeof string, "You have set %s as a Co-Owner.", PlayerName(targetplayer));
SendClientMessage(playerid, COLOR_ORANGE, string);
}
if(Level == 5)
{
format(string, sizeof string, "You have been set to the server Owner by %s.", PlayerName(playerid));
SendClientMessage(targetplayer, COLOR_LEMON, string);
format(string, sizeof string, "You have set %s to the server Owner.", PlayerName(targetplayer));
SendClientMessage(playerid, COLOR_LEMON, string);
}
printf("[SETADMIN] %s has set %s as an admin ( %i )", PlayerName(playerid), PlayerName(targetplayer), Level);
PlayerInfo[targetplayer][AdminLevel] = Level;
return 1;
}