pawn Код:
if(strcmp(cmd, "/setadmin",true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new tmp[256];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid,cmd,"[PartOfName/ID] [admin level]");
return 1;
}
if(!IsNumeric(tmp) && (PlayerID(tmp)==-2 || PlayerID(tmp)==-1))
{
SendClientError(playerid, "ID not found. Invalid part of name or multiple results");
return 1;
}
if(!IsNumeric(tmp) && PlayerID(tmp)>=0) giveplayerid = PlayerID(tmp);
if(IsNumeric(tmp)) giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid))
{
SendClientError(playerid, "ID not found. Invalid part of name or multiple results");
return 1;
}
if(giveplayerid==playerid) return 1;
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientUsage(playerid,cmd,"[PartOfName/ID] [admin level]");
return 1;
}
new adminlvl=strval(tmp);
if(adminlvl < 0 || adminlvl > 31337) return SendClientError(playerid,"Admin level cannot be below 0 or above 12");
if(PlayerInfo[giveplayerid][power]==adminlvl) return SendClientError(playerid,"This admin is already that admin level");
new stringa[MAX_STRING];
if(adminlvl==1 && PlayerInfo[giveplayerid][power]==0) {
format(stringa,sizeof(stringa),"=>>> %s has been promoted to trial admin - Congratulations <<<=",NameEx(giveplayerid));
SendClientMessageToAll(COLOR_GREENYELLOW,stringa);
PlayerInfo[giveplayerid][power]=1;
dUserSetINT(PlayerName(giveplayerid)).("power",1);
return 1;
}
else if(adminlvl>1 && PlayerInfo[giveplayerid][power]>0 && PlayerInfo[giveplayerid][power]<adminlvl) {
format(stringa,sizeof(stringa),"=>>> Admin %s has been promoted from admin level %d to admin level %d - Congratulations <<<=",NameEx(giveplayerid),PlayerInfo[giveplayerid][power],adminlvl);
SendAdminMessage(COLOR_GREENYELLOW, stringa);
PlayerInfo[giveplayerid][power]=adminlvl;
dUserSetINT(PlayerName(giveplayerid)).("power",adminlvl);
return 1;
}
else if(adminlvl>1 && PlayerInfo[giveplayerid][power]==0)
{
SendClientInfoEx(playerid,"%s has been promoted to admin level %d successfully",NameEx(giveplayerid),adminlvl);
SendClientInfoEx(giveplayerid,"You have been promoted to admin level %d by Admin %s",adminlvl,NameEx(playerid));
PlayerInfo[giveplayerid][power]=adminlvl;
dUserSetINT(PlayerName(giveplayerid)).("power",adminlvl);
return 1;
}
else if(adminlvl>1 && PlayerInfo[giveplayerid][power]>adminlvl)
{
SendClientInfoEx(playerid,"%s has been demoted from admin level %d to admin level %d",NameEx(giveplayerid),PlayerInfo[giveplayerid][power],adminlvl);
SendClientInfoEx(giveplayerid,"You have been demoted from admin level %d to admin level %d by Admin %s",PlayerInfo[giveplayerid][power],adminlvl,NameEx(playerid));
PlayerInfo[giveplayerid][power]=adminlvl;
dUserSetINT(PlayerName(giveplayerid)).("power",adminlvl);
return 1;
}
else if(adminlvl==0 && PlayerInfo[giveplayerid][power]>0)
{
SendClientInfoEx(giveplayerid,"You have been removed from admin team by admin %s",NameEx(playerid));
SendClientInfoEx(playerid,"You removed %s from admin team",NameEx(giveplayerid));
PlayerInfo[giveplayerid][power]=0;
dUserSetINT(PlayerName(giveplayerid)).("power",0);
return 1;
}
}
}