SA-MP Forums Archive
Run time error 4: "Array index out of bounds" - 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: Run time error 4: "Array index out of bounds" (/showthread.php?tid=628694)



Run time error 4: "Array index out of bounds" - Banditul18 - 13.02.2017

Hello , i open my server log and i se this:
PHP код:
[15:52:08] [debugRun time error 4"Array index out of bounds"
[15:52:08] [debug]  Attempted to read/write array element at index 65535 in array of size 50
[15:52:08] [debugAMX backtrace:
[
15:52:08] [debug#0 000be7e4 in public cmd_id (playerid=7, params[]=@003926a0 "3") at E:\V1-1.1.1\pawno\include\PPC_PlayerCommands.inc:5759
[15:52:08] [debug#1 native CallLocalFunction () from samp03svr
[15:52:08] [debug#2 00008c90 in public OnPlayerCommandText (playerid=7, cmdtext[]=@00392688 "/id 3") at E:\V1-1.1.1\pawno\include\izcmd.inc:112 
The command its this:
PHP код:
CMD:id(playeridparams[])
{
    new 
idstring[144];
    if(
sscanf(params"u"id))
        return 
SendClientMessage(playeridCOLOR_RED,"Use: /id [Nume/ID]");
    
format(stringsizeof(string), "Name:%s(%i) | Scor:%i | Class:%s | Admin:%i | VIP:%i"pName(id), id,APlayerData[id][PlayerScore], GetPlayerClassEx(id), APlayerData[id][PlayerLevel], APlayerData[id][VPlayerLevel]);
    
SendClientMessage(playeridGreystring);
    return 
1;

I need to check the invalid playerid id or something?


Re: Run time error 4: "Array index out of bounds" - JesterlJoker - 13.02.2017

This problem is already solved

https://sampforum.blast.hk/showthread.php?tid=628680


Re: Run time error 4: "Array index out of bounds" - Mic_H - 13.02.2017

Yes you need to check for INVALID_PLAYER_ID
PHP код:
CMD:id(playeridparams[]) 

    new 
idstring[144]; 
    if(
sscanf(params"u"id)) 
        return 
SendClientMessage(playeridCOLOR_RED,"Use: /id [Nume/ID]"); 
    if(
id != INVALID_PLAYER_ID)
    {
        
format(stringsizeof(string), "Name:%s(%i) | Scor:%i | Class:%s | Admin:%i | VIP:%i"pName(id), id,APlayerData[id][PlayerScore], GetPlayerClassEx(id), APlayerData[id][PlayerLevel], APlayerData[id][VPlayerLevel]); 
        
SendClientMessage(playeridGreystring); 
    }
    else 
        return 
SendClientMessage(playeridCOLOR_RED"Error: Invalid PlayerID/PlayerName.");
    return 
1




Re: Run time error 4: "Array index out of bounds" - JesterlJoker - 13.02.2017

This problem is already solved

https://sampforum.blast.hk/showthread.php?tid=628680