[HELP] Targetid is egnored ?
#4

Hey Eoussama,

What Rdx means by the above is that line 10 you run the code to set their level (MAX_PLAYERS + 1) times - because you have a for loop <= MAX_PLAYERS there.

In terms of it only ever working for you - your sscanf looks fine to me, but there are an array of oddities that could be causing us to miss something further on in addition to the for loop. Could you try running the below and pasting the console output and what happens ingame?

Also string[MAX_PLAYER_NAME+64] is probably too small - I would put it as string[MAX_PLAYER_NAME*2 + 64] if you want to continue with two names!

PHP код:
CMD:setlevel(playeridparams[]) 
{
    new
        
string[MAX_PLAYER_NAME+64],
        
pname[MAX_PLAYER_NAME],
        
tname[MAX_PLAYER_NAME],
        
targetid,
        
level;
        
    if((
IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] >= 3
    {
         if(
sscanf(params"ui"targetidlevel)) 
        {
            return 
SendClientMessage(playerid0xFF0000"USAGE: /makeadmin (playerid) (level)");
        }
        
        
printf("** %i, %i, '%s'"playeridtargetidparams);
        
        if((!
IsPlayerConnected(targetid)) || (targetid == INVALID_PLAYER_ID)) 
        {
            
SendClientMessage(playerid0xFF0000"Player Is Not Connected!");
        }
        else 
        {
            if(
level || level 4
            {
                return 
SendClientMessageplayerid0xFF0000"available levels (1-4)");
            }
            
            
GetPlayerName(playeridpnamesizeof(pname));
            
GetPlayerName(targetidtnamesizeof(tname));
            
format(stringsizeof(string), "Administrator %s has promoted %s to level %i admin"pnametnamelevel);
            
SendClientMessageToAll(-1string);
            
PlayerInfo[targetid][AdminLevel] = level;
            new 
INI:File INI_Open(AdminPath(targetid));
            
INI_SetTag(File"AdminData");
            
INI_WriteInt(File"AdminLevel"PlayerInfo[targetid][AdminLevel]);
            
INI_Close(File);
            return 
1;
        }
    }
    else 
    {
         
SendClientMessageplayerid0xFF0000"you can't use this command!");
        return 
1;
    }
    return 
1;

Reply


Messages In This Thread
[HELP] Targetid is egnored ? - by Eoussama - 03.10.2016, 23:56
Re: [HELP] Targetid is egnored ? - by Rdx - 04.10.2016, 00:12
Re: [HELP] Targetid is egnored ? - by Jefff - 04.10.2016, 00:15
Re: [HELP] Targetid is egnored ? - by Alcatrik - 04.10.2016, 00:31
Re: [HELP] Targetid is egnored ? - by Eoussama - 04.10.2016, 00:39
Re: [HELP] Targetid is egnored ? - by Alcatrik - 04.10.2016, 00:43
Re: [HELP] Targetid is egnored ? - by Eoussama - 04.10.2016, 01:04
Re: [HELP] Targetid is egnored ? - by Eoussama - 04.10.2016, 10:56
Re: [HELP] Targetid is egnored ? - by Threshold - 04.10.2016, 13:23
Re: [HELP] Targetid is egnored ? - by Rdx - 04.10.2016, 13:39

Forum Jump:


Users browsing this thread: 1 Guest(s)