24.04.2013, 12:20
(
Последний раз редактировалось LeeXian99; 25.04.2013 в 03:19.
)
pawn Код:
CMD:setlevel(playerid,params[])
{
new targetid, alevel, arank[32];
new string[256], string2[256], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
if(IsPlayerAdmin(playerid) || pInfo[playerid][ALevel] > 4)
{
if(sscanf(params, "ui", targetid, alevel)) return SendClientMessage(playerid, yellow, "[USAGE]: /setlevel [playerid] [level]");
else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "[ERROR]: The player is not connected!");
else if(alevel < 0|| alevel > 4) return SendClientMessage(playerid, red, "[ERROR]: Invalid level, only 1 - 4.");
if(alevel == pInfo[targetid][ALevel]) return SendClientMessage(playerid, red, "[ERROR]: Player is in current level!");
if(alevel >= 1)
{
switch(alevel)
{
case 0:arank = "Player";
case 1:arank = "Moderator";
case 2:arank = "Administrator";
case 3:arank = "Head Administrator";
case 4:arank = "Server Owner";
}
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, name2, sizeof(name2));
GameTextForPlayer(targetid, "PROMOTED!", 5000, 3);
format(string, sizeof(string), "Server Owner %s (ID: %i) has promoted you to %s (Level %i)", name, playerid, arank, alevel);
format(string2, sizeof(string2), "%s (ID: %i) has been promoted to %s (Level %i)", name2, playerid, arank, alevel);
SendClientMessage(targetid, aqua, string);
SendClientMessageToAll(aqua, string2);
PlayerPlaySound(targetid, 1057, 0, 0, 0);
PlayerPlaySound(playerid, 1057, 0, 0, 0);
pInfo[targetid][ALevel] = alevel;
}
else if(alevel != pInfo[targetid][ALevel])
{
switch(alevel)
{
case 0:arank = "Player";
case 1:arank = "Moderator";
case 2:arank = "Administrator";
case 3:arank = "Head Administrator";
case 4:arank = "Server Owner";
}
GameTextForPlayer(targetid, "DEMOTED!", 5000, 3);
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, name2, sizeof(name2));
format(string, sizeof(string), "Server Owner %s (ID: %i) has demoted you to %s (Level %i)", name, playerid, arank, alevel);
format(string2,sizeof(string2), "%s (ID: %i) has been demoted to %s (Level %i)", name2, playerid, arank, alevel);
SendClientMessage(targetid, aqua, string);
SendClientMessageToAll(aqua, string2);
PlayerPlaySound(targetid, 1057, 0, 0, 0);
PlayerPlaySound(playerid, 1057, 0, 0, 0);
pInfo[targetid][ALevel] = alevel;
}
new INI:file = INI_Open(Path(targetid));
INI_WriteInt(file, "AdminLevel", pInfo[targetid][ALevel]);
INI_Close(file);
}
else return SendClientMessage(playerid, red, "[ERROR]: You're not supposed to use this, admin-hunger.");
return 1;
}