remove admin cmd and makeadmin
#1

Код:
CMD:makeadmin(playerid, params[]) 
{  
    new id, string[128], level, code[5]; 
    generateCode(code, 5); 
    if(PlayerInfo[playerid][pAdmin] < 7)  
        return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");  
         
    if(sscanf(params, "dd", id, level))  
        return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");  

    format(string, sizeof(string), "%s promoted you to level %i.\nSecurity Code: %s", PlayerName(playerid), level, code); 
    ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");  
     
    format(string, sizeof(string), "You promoted %s to level %i.", PlayerName(id), level);  
    SendClientMessage(playerid, COLOR_BLUE, string); 
     
    PlayerInfo[id][pAdmin] = level;  
    format(AdminKod[playerid], 6, code); // Stores the code into the string 
    return 1;  
}
There is problem..When i set player admin level to zero he must go relog to save that and if he is level 0 he still get security code
Reply
#2

EDIT: Try this instead:

Код:
CMD:makeadmin(playerid, params[]) 
{  
    new id, string[128], level, code[5]; 
    generateCode(code, 5); 
    if(PlayerInfo[playerid][pAdmin] < 7)  
        return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");  
         
    if(sscanf(params, "ud", id, level))  
        return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");  
    else if(level < 1) return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");  
    format(string, sizeof(string), "%s promoted you to level %i.\nSecurity Code: %s", PlayerName(playerid), level, code); 
    ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");  
     
    format(string, sizeof(string), "You promoted %s to level %i.", PlayerName(id), level);  
    SendClientMessage(playerid, COLOR_BLUE, string); 
     
    PlayerInfo[id][pAdmin] = level;  
    format(AdminKod[playerid], 6, code); // Stores the code into the string 
    return 1;  
}
Reply
#3

Hey, I fixed that issue for you.

PHP код:
CMD:makeadmin(playeridparams[]) 
{  
    new 
idstring[128], levelcode[5]; 
    if(
PlayerInfo[playerid][pAdmin] < 7)  
        return 
SendClientMessage(playeridCOLOR_BLUE"You don't have acces to that command.");  
         
    if(
sscanf(params"dd"idlevel))  
        return 
SendClientMessage(playeridCOLOR_RED"SERVER: /makeadmin [ID] [LEVEL]");  
    if(
level == 0)
    {
        
format(stringsizeof(string), "%s has removed your admin level."PlayerName(playerid)); 
        
ShowPlayerDialog(idDIALOG_ADMINBOXDIALOG_STYLE_MSGBOX"Sorry..."string"Ok"""); 
        
        
format(stringsizeof(string), "You removed %s's admin level."PlayerName(id));  
        
SendClientMessage(playeridCOLOR_BLUEstring);
        
PlayerInfo[id][pAdmin] = 0;
        
AdminKod[playerid][0] = EOS;
    }
    else
    {
        
generateCode(code5); 
        
format(stringsizeof(string), "%s promoted you to level %i.\nSecurity Code: %s"PlayerName(playerid), levelcode); 
        
ShowPlayerDialog(idDIALOG_ADMINBOXDIALOG_STYLE_MSGBOX"You are an admin"string"Ok""");  
         
        
format(stringsizeof(string), "You promoted %s to level %i."PlayerName(id), level);  
        
SendClientMessage(playeridCOLOR_BLUEstring); 
        
        
PlayerInfo[id][pAdmin] = level;
        
format(AdminKod[playerid], 6code);
    }
    return 
1;  

If it doesn't work, let me know.

Also, when you change their admin level, it will generate a new code for them.
Reply
#4

On this line i get errors and warnings
Quote:

AdminKod[playerid][0] = EOS;

::
Quote:

warning 215: expression has no effect
error 001: expected token: ";", but found "["
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
fatal error 107: too many error messages on one line

Reply
#5

Change
PHP код:
AdminKod[MAX_PLAYERS]; 
to

PHP код:
AdminKod[MAX_PLAYERS][5]; 
Reply
#6

now everything work fine but when he is still in game and i delete him admin position he can still log in as administrator.
Reply
#7

and when he have admin and writte wrong code he log in server doesnt send SCM wrong code and also i get warning from log sscanf warning: String buffer overflow
Reply
#8

someone?
Reply
#9

Ok I'm giving you my /makeadmin
First of all if you want to use this command you must login into your RCON admin
PHP код:
CMD:makeadmin(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-4,"Only Klevis is allowed to use this command.");//Checking if the player is rcon admin to set an admin level
    
new idlevel;//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,-1,"USAGE: /makeadmin <id> <level>");//Check if the player inputted a username or id and a admin level.
    
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,-4,"That player is not connected!");//Checking if the selected user is connected or not.
    
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);
    if(!
fexist(file)) return SendClientMessage(playerid,-4,"That player is not registered");//Checking if the player is not registered
    
INI_Open(file);//Opening the file with SII include
    
INI_WriteInt("Level",level);//Writing the line "Level" the selected admin level.
    
INI_Save();//Saving the file
    
INI_Close();//Closing the file
    
PInfo[id][Level] = level;
    
SendClientMessage(playerid,-1,"You have promoted to Admin.");
    
SendClientMessage(id,COLOR_PURPLE,"You've been made an Admin by Klevis, use /a to chat with other admins.");
    return 
1;

I also tested it and works fine. You can edit it if ya want
_______________________________

Don't forget to REP+ me. And if you need something else please feel free to send me a PM.
Reply
#10

It doesnt have anything to do with the makeadmin, its the login command you made show me the code for it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)