07.10.2014, 12:40
pawn Код:
CMD:promote(playerid, params[]) {
new targetid, adminlvl, string[128], string2[128], adminstring[124];
if(PlayerInfo[playerid][pAdmin] == 0) {
return 0;
} else {
if(sscanf(params, "dd", targetid, adminlvl)) return SendClientMessage(playerid, COLOR_GOLDENROD, "Usage: /promote [id] [level]");
if(adminlvl < 0 || adminlvl > 4) return SendClientMessage(playerid, COLOR_GOLDENROD, "Invalid Admin Level!");
if(playerid == targetid) return SendClientMessage(playerid, COLOR_GOLDENROD, "You can't promote yourself!");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GOLDENROD, "This player is not connected!");
if(PlayerInfo[playerid][pAdmin] >= 3) {
switch(adminlvl)
{
case 1: adminstring = "moderator(1)";
case 2: adminstring = "administrator(2)";
case 3: adminstring = "manager(3)";
case 4: adminstring = "owner(4)";
case 5: adminstring = "regular player(0)";
}
format(string, sizeof(string), "You have been promoted to %s by %s", adminstring, GetName(playerid));
format(string2, sizeof(string2), "You have promoted %s to %s", GetName(targetid), adminstring);
SendClientMessage(playerid, COLOR_GOLDENROD, string);
SendClientMessage(targetid, COLOR_GOLDENROD, string2);
PlayerInfo[targetid][pAdmin] = adminlvl;
new INI:File = INI_Open(UserPath(targetid));
INI_SetTag(File, "data");
INI_WriteInt(File, "Admin", PlayerInfo[targetid][pAdmin]);
INI_Close(File);
return 1;
} else return SendClientMessage(playerid, COLOR_GOLDENROD, "You can't promote if your not a manager or higher admin level!");
}
}