Admin Level HELP !
#10

Below code should work perfectly fine.

PHP код:
CMD:setlevel(playeridparams[])
{
    
//check if the player is a admin
    
LevelCheck(playerid5);
    new 
targetlevel;
    if(
sscanf(params"ui"targetlevel)) return SendClientMessage(playeridCOLOR_THISTLE"USAGE: /setlevel [player] [level]");
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: The specified player is not conected.");
    if(
GetPlayerGAdminLevel(playerid) < GetPlayerGAdminLevel(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: You cannot use this command on higher level admin.");
    if(
level || level MAX_ADMIN_LEVELS) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: Invalid level, mus be b/w 0-"#MAX_ADMIN_LEVELS".");
    
if(level == GetPlayerGAdminLevel(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: Player is already of that level.");
    new 
string[144];
    if(
GetPlayerGAdminLevel(playerid) < level)
    {
        
GameTextForPlayer(target"~g~~h~~h~~h~Promoted"50001);
        
format(stringsizeof(string), "You have been promoted to admin level %i by %s[%i], Congratulation."levelReturnPlayerName(playerid), playerid);
        
SendClientMessage(targetCOLOR_DODGER_BLUEstring);
        
format(stringsizeof(string), "You have promoted %s[%i] to admin level %i."ReturnPlayerName(target), targetlevel);
        
SendClientMessage(playeridCOLOR_DODGER_BLUEstring);
    }
    else if(
GetPlayerGAdminLevel(playerid) > level)
    {
        
GameTextForPlayer(target"~r~~h~~h~~h~Demoted"50001);
        
format(stringsizeof(string), "You have been demoted to admin level %i by %s[%i], Sorry."levelReturnPlayerName(playerid), playerid);
        
SendClientMessage(targetCOLOR_DODGER_BLUEstring);
        
format(stringsizeof(string), "You have demoted %s[%i] to admin level %i."ReturnPlayerName(target), targetlevel);
        
SendClientMessage(playeridCOLOR_DODGER_BLUEstring);
    }
    
PlayerPlaySound(target10570.00.00.0);
    
PlayerPlaySound(playerid10570.00.00.0);
    new 
key DB::RetrieveKey(gGlobal[s_usertable], "username"ReturnPlayerName(target)); // It was "playerid" should be "target"
    
DB::SetIntEntry(gGlobal[s_usertable], key"admin"level);
        
gUser[target][u_admin] = level;
    return 
1;

Reply


Messages In This Thread
Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 08:53
Re: Admin Level HELP ! - by Allihopp - 24.01.2017, 08:54
Re: Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 09:06
Re: Admin Level HELP ! - by iLearner - 24.01.2017, 09:14
Re: Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 09:16
Re: Admin Level HELP ! - by iLearner - 24.01.2017, 09:34
Re: Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 10:11
Re: Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 10:20
Re: Admin Level HELP ! - by GhostKiller123 - 24.01.2017, 10:24
Re: Admin Level HELP ! - by AjaxM - 24.01.2017, 11:56

Forum Jump:


Users browsing this thread: 1 Guest(s)