SA-MP Forums Archive
Admin set problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Admin set problem (/showthread.php?tid=507626)



Admin set problem - Roddan - 18.04.2014

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;




Re : Admin set problem - S4t3K - 18.04.2014

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.


Re: Admin set problem - Konstantinos - 18.04.2014

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