Admin set problem
#1

Hello. I followed a guide like 1 year ago and now when I try to use my command /setadmin it dosen't set my admin. It displays: That user is not connected.

here is the code.

PHP код:
CMD:setadmin(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid))return 0//This command only works for rcon
    
if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA"USAGE: /setadmin [ID] [Level 1-6]");//it will show this if you dont use the format properly
    
if(levels 6) return SendClientMessage(playerid,0xFF0000FF,"LEVELS AVAILABLE 1-6!");//Available levels
    
if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0x99CEFFFF,"That user is not connected.");//Detect if the id/partofname is connected
    
if(pInfo[ID][pAdmin] == levels) return SendClientMessage(playerid,0xFF0000FF"ERROR: That person is already this admin level!");//Detect if the guy is already the level you setted
    
GetPlayerName(playerid,NamMAX_PLAYER_NAME);//define the playerid name
    
GetPlayerName(ID,pname,MAX_PLAYER_NAME);//define the other person name
    
new str[128];
    if(
levels == 0)
    {
        
format(strsizeof(str),"%s has set your Admin level to %d.",Nam,levels);
        
SendClientMessage(ID,0x1BE091FF,str);
        
format(strsizeof(str),"You had set %s Admin level to %d!",pname,levels);
        
SendClientMessage(playerid,0x1BE091FF,str);
        
pInfo[ID][pAdmin] = levels;//this sets the player level
        
return 1;
    }
    
format(strsizeof(str),"%s has set your Admin level to %d.",Nam,levels);
    
SendClientMessage(ID,0x1BE091FF,str);
    
format(strsizeof(str),"You have set %s Admin level to %d!",pname,levels);
    
SendClientMessage(playerid,0x1BE091FF,str);
    
pInfo[ID][pAdmin] = levels;
    return 
1;

Reply
#2

If you doesn't initialize the ID and levels variables, how do you want this to work ?
Also, what's the difference between the code in the "if" and the code which follows the end of the "if" condition ?
Wasted optimization.
Reply
#3

Update both your sscanf plugin and sscanf include, re-compile your scripts and try again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)