31.10.2013, 18:22
Some hackers can set their admin level to level 4 and Ban Players , is it a problem in the script ?
pawn Код:
dcmd_setadmin(playerid,params[])
{
new string[128];
new string2[128];
new ID;
new cmdreason;
if(sscanf(params,"ui",ID,cmdreason))
{
SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[INFO]{FFFFFF}: /setadmin (Player Name/ID) (Level)");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be spawned to use any command.");
return 1;
}
if(IsPlayerAdmin(playerid))
{
AdminLevel[ID] =cmdreason;
SendClientMessage(playerid,COLOR_DODGERBLUE,"This Player's Admin Level has been changed");
return 1;
}
if(AdminLevel[playerid] <= 2)
{
GameTextForPlayer(playerid,"~w~Wrong Command, Read ~p~/commands~w~or ~p~/cmds ~w~to know your Commands",3000,3);
return 1;
}
if(ID == INVALID_PLAYER_ID)
{
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot set their administrator level.",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(PLAYERLIST_authed[ID] != 1)
{
format(string,sizeof(string),"%s(%d) is not logged into to the server. You must wait till they login before you set their administrator level.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(AdminLevel[playerid] == 3 && cmdreason >= 3)
{
SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[ERROR]{FFFFFF}You can only set from 1-2 Admin Level");
return 1;
}
if(AdminLevel[playerid] == 4 && cmdreason >= 5)
{
SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[ERROR]{FFFFFF}You can only set from 1-4 Admin Level");
return 1;
}
if(AdminLevel[playerid] == 5 && cmdreason >= 6)
{
SendClientMessage(playerid,COLOR_ERROR,"{CACA00}[ERROR]{FFFFFF}You can only set from 1-5 Admin Level");
return 1;
}
if(AdminLevel[ID] > AdminLevel[playerid])
{
format(string,sizeof(string),"%s(%d) Level's is more than your Level you can't Set His admin Level",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(AdminLevel[ID] == cmdreason)
{
format(string,sizeof(string),"%s(%d) is already at the Administrator level: %d",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
format(string,sizeof(string),"Administrator %s(%d) have given you Admin Level : %d.",PlayerName(playerid),playerid,cmdreason);
SendClientMessage(ID,COLOR_ADMIN,string);
AdminLevel[ID] =cmdreason;
format(string,sizeof(string),"You have given %s(%d) Admin Level : %d.",PlayerName(ID),ID,cmdreason);
SendClientMessage(playerid,COLOR_ADMIN,string);
format(string,sizeof(string),"9[ADMIN LEVEL CHANGE] %s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
format(string,sizeof(string),"[ADMIN-COMMAND] %s(%d) has used /setadmin on %s(%d)",PlayerName(playerid),playerid,PlayerName(ID),ID);
SendClientMessageToAllAdmins(string);
format(string2,sizeof(string2),"%s(%d) has given %s(%d) the administrator level %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
AdminLog(string2);
return 1;
}