SA-MP Forums Archive
Errors in crashdetect "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: Errors in crashdetect "Array index out of bounds" (/showthread.php?tid=321919)



Errors in crashdetect "Array index out of bounds" - tal_peretz - 29.02.2012

I used this -

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

when I do something that what show in the server_log -

PHP код:
[03:17:34] [debugRun time error 4"Array index out of bounds"
[03:17:34] [debug]   Accessing element at index 50 past array upper bound 121
[03:17:34] [debugBacktrace (most recent call first):
[
03:17:34] [debug#0  public OnPlayerObjectMoved()+0x1c1fac from TalDmMod.amx
[03:17:34] [debugRun time error 4"Array index out of bounds"
[03:17:34] [debug]   Accessing element at index 50 past array upper bound 121
[03:17:34] [debugBacktrace (most recent call first): 
What's wrong in that code ?

PHP код:
public OnPlayerObjectMoved(playerid,objectid)
{
    for ( new 
0<MAX_OBJECTSi++ )
    {
        if ( 
objectid == A_Objects][playerid] )
        {
            if ( 
IsValidPlayerObjectplayeridA_Objects][playerid] ) )
            {
                  
DestroyPlayerObjectplayeridA_Objects][playerid] );
                
PlayerObjects[playerid]--;
                if ( 
PlayerObjects[playerid] == && Objects_Hit2[playerid] != 200)
                  {
                      
Objects_Missed[playerid] = 200 Objects_Hit2[playerid];
                        
MoveObjectsForPlayerAgainplayerid );
                }
            }
        }
    }
    return 
1;

Thanks Alot


Re: Errors in crashdetect "Array index out of bounds" - JamesC - 29.02.2012

Show us your definition of 'A_Objects'. It could be that you've defined it as A_Objects[MAX_PLAYERS][MAX_OBJECTS] and are using A_Objects[MAX_OBJECTS][MAX_PLAYERS].


Re: Errors in crashdetect "Array index out of bounds" - tal_peretz - 29.02.2012

PHP код:
A_Objects50 ][ MAX_PLAYERS ], 



Re: Errors in crashdetect "Array index out of bounds" - tal_peretz - 29.02.2012

I think it's create more than 50 objects .. maybe because of that ?


Re: Errors in crashdetect "Array index out of bounds" - Psymetrix - 29.02.2012

Change it to
pawn Код:
A_Objects[ MAX_OBJECTS ][ MAX_PLAYERS ]



Re: Errors in crashdetect "Array index out of bounds" - tal_peretz - 29.02.2012

Fixed thank you !