12.04.2014, 14:25
I wanted to put something like to prevent people from demoting high level admins for example i'am a Community Director but Executive Admins can use /makeadmin on me and demote me to Level 1 so i want a script to prevent this but i really didn't know how
pawn Код:
if(strcmp(cmd, "/makeadmin", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 99999)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid/PartOfName] [level]");
return 1;
}
new para1;
new level;
para1 = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid/PartOfName] [level]");
return 1;
}
level = strvalEx(tmp);
if(level > 99999 || level < 0) { SendClientMessage(playerid, COLOR_GREY, " Don't go below number 0, or above number 99999 (1/2/3/4/1337/99999) !"); return 1; }
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
strmid(giveplayer, PlayerRPName(para1), 0, MAX_PLAYER_NAME);
strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
if(level < 2) PlayerInfo[para1][pTag] = NTAG_PLAYER;
else PlayerInfo[para1][pTag] = NTAG_ADMIN;
if(level > 0)
{
new rand = random(9999);
PlayerInfo[para1][pSecKey] = rand;
gAdminAuthorized[para1] = 1;
}
if(level > PlayerInfo[para1][pAdmin])
{
format(string, sizeof(string), " You have been promoted to a level %d admin by %s, your security key is %d.", level, sendername, PlayerInfo[para1][pSecKey]);
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " You have promoted %s to a level %d admin.", giveplayer,level);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
else
{
format(string, sizeof(string), " You have been demoted to a level %d admin by %s, your security key is %d.", level, sendername, PlayerInfo[para1][pSecKey]);
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " You have demoted %s to a level %d admin.", giveplayer,level);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
}
PlayerInfo[para1][pAdmin] = level;
if(level < 1)
{
PlayerInfo[para1][pAdmin] = 0;
PlayerInfo[para1][pSecKey] = 0;
gAdminAuthorized[para1] = 0;
}
}
}
}
}