Errors in crashdetect "Array index out of bounds"
#1

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] [debug] Run 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] [debug] Backtrace (most recent call first):
[
03:17:34] [debug] #0  public OnPlayerObjectMoved()+0x1c1fac from TalDmMod.amx
[03:17:34] [debug] Run 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] [debug] Backtrace (most recent call first): 
What's wrong in that code ?

PHP код:
public OnPlayerObjectMoved(playerid,objectid)
{
    for ( new 
i = 0; i <MAX_OBJECTS; i++ )
    {
        if ( 
objectid == A_Objects[ i ][playerid] )
        {
            if ( 
IsValidPlayerObject( playerid, A_Objects[ i ][playerid] ) )
            {
                  
DestroyPlayerObject( playerid, A_Objects[ i ][playerid] );
                
PlayerObjects[playerid]--;
                if ( 
PlayerObjects[playerid] == 0 && Objects_Hit2[playerid] != 200)
                  {
                      
Objects_Missed[playerid] = 200 - Objects_Hit2[playerid];
                        
MoveObjectsForPlayerAgain( playerid );
                }
            }
        }
    }
    return 
1;
} 
Thanks Alot
Reply
#2

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].
Reply
#3

PHP код:
A_Objects[ 50 ][ MAX_PLAYERS ], 
Reply
#4

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

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

Fixed thank you !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)