01.03.2014, 16:06
I assume that you don't set a player's admin level to 5 when you login into RCON.
OR instead, simply do -
pawn Код:
CMD:setlevel(playerid,params[])
{
if(PlayerInfo[playerid][Level] < 4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xF69521AA,"You can't use this command!");//Doesn't let admins under level 4 set an admin level
new id, level;//Creating the id variable to store the selected id and a level variable for the chosen admin level.
if(sscanf(params,"ui",id,level)) return SendClientMessage(playerid,0xF69521AA,"USAGE: /setlevel [id] [level(1-4)]");//Check if the player inputted a username or id and a admin level.
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xF69521AA,"The specified player is currently not connected!");//Checking if the selected user is connected or not.
if (!(0 <= level <= 4)) return SendClientMessage(playerid,0xF69521AA,"Please specify an admin level between 0 and 4");
new file[64],PlayerName[24];//Creating a variable to store the file path, and a variable to store the players name.
GetPlayerName(id,PlayerName,sizeof PlayerName);//Retrieving the selected id's name,
format(file,sizeof file,"Admin/%s.ini",PlayerName);
PlayerInfo[id][Level] = level;
SendClientMessage(playerid,0xF69521AA,"You have successfully changed the selected user's admin level");
SendClientMessage(id,0xF69521AA,"Your admin level has successfully been changed, congratulations!");
return 1;
}
pawn Код:
stock GetPlayerFromIP( ip[] )
{
new pIP[16];
for(new i = 0; i < MAX_PLAYERS; i++)
{
GetPlayerIp(playerid, pIP, 16);
if( !strcmp( pIP, ip ) ) return i;
else continue;
}
return -1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
if(success)
{
if( GetPlayerFromIP( ip ) != -1 ) return ( PlayerInfo[playerid][Level] = 4 );
}
return 1;
}