Run time error 4: "Array index out of bounds" -
nGen.SoNNy - 02.11.2013
After 12-13 hours of running well...
pawn Код:
[02/11/2013 12:05:31] [debug] Run time error 4: "Array index out of bounds"
[02/11/2013 12:05:31] [debug] Accessing element at index 65535 past array upper bound 1999
[02/11/2013 12:05:31] [debug] AMX backtrace:
[02/11/2013 12:05:31] [debug] #0 000e3d04 in public CarSpawner (playerid=9, model=522) at C:\Documents and Settings\user\Desktop\Stunt Evolution - Beta\gamemodes\STUNT-EVOLUTION.pwn:17794
[02/11/2013 12:05:31] [debug] #1 0011f484 in public cmd_nrg (playerid=9, params[]=@0x002f5748 "") at C:\Documents and Settings\user\Desktop\Stunt Evolution - Beta\gamemodes\STUNT-EVOLUTION.pwn:22335
[02/11/2013 12:05:31] [debug] #2 00009464 in public OnPlayerCommandText (playerid=9, cmdtext[]=@0x002f5734 "") at C:\Documents and Settings\user\Desktop\Stunt Evolution - Beta\pawno\include\zcmd.inc:102
pawn Код:
function CarSpawner( playerid, model )
{
if ( IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You already drive a car!" );
else
{
new
Float:x,
Float:y,
Float:z,
Float:angle
;
GetPlayerPos( playerid, x, y, z );
GetPlayerFacingAngle( playerid, angle );
if ( PlayerInfo[ playerid ][ pCar ] != -1 )
CarDeleter( PlayerInfo[ playerid ][ pCar ] );
new vehicleid = CreateVehicle( model, x, y, z, angle, -1, -1, -1 );
PutPlayerInVehicle( playerid, vehicleid, 0 );
SetVehicleNumberPlate( vehicleid, ""R"S"W"tun"O"T" );
SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
ChangeVehicleColor( vehicleid, 0,7 );
PlayerInfo[ playerid ][ pCar ] = vehicleid;
format( VehicleOwner[ vehicleid ], 25, "Server" );
for ( new Any = 0; Any < MAX_VEHICLE_ATTACHED_OBJECTS; Any++ )
if ( IsValidDynamicObject( p_Object[ playerid ][ Any ] ) )
DestroyDynamicObject( p_Object[ playerid ][ Any ] );
}
return ( 1 );
}
CMD:nrg( playerid, params[ ] )
{
if ( IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You already have a vehicle!" );
CarSpawner( playerid, 522 );
SendClientMessage( playerid, COLOR_ABLUE, "Enjoy your new bike!" );
return ( 1 );
}
Re: Run time error 4: "Array index out of bounds" -
Konstantinos - 02.11.2013
I wasn't about to post because you were rude on the previous thread and like I told you there, it was NOT from the /car command.
The crash is caused at CarSpawner function and from that line:
pawn Код:
format( VehicleOwner[ vehicleid ], 25, "Server" );
vehicleid is INVALID_VEHICLE_ID (65535).
pawn Код:
function CarSpawner( playerid, model )
{
if ( IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You already drive a car!" );
else
{
new
Float:x,
Float:y,
Float:z,
Float:angle
;
GetPlayerPos( playerid, x, y, z );
GetPlayerFacingAngle( playerid, angle );
if ( PlayerInfo[ playerid ][ pCar ] != -1 )
CarDeleter( PlayerInfo[ playerid ][ pCar ] );
new vehicleid = CreateVehicle( model, x, y, z, angle, -1, -1, -1 );
if( vehicleid != INVALID_VEHICLE_ID )
{
PutPlayerInVehicle( playerid, vehicleid, 0 );
SetVehicleNumberPlate( vehicleid, ""R"S"W"tun"O"T" );
SetVehicleVirtualWorld( vehicleid, GetPlayerVirtualWorld( playerid ) );
LinkVehicleToInterior( vehicleid, GetPlayerInterior( playerid ) );
ChangeVehicleColor( vehicleid, 0,7 );
PlayerInfo[ playerid ][ pCar ] = vehicleid;
format( VehicleOwner[ vehicleid ], 25, "Server" );
for ( new Any = 0; Any < MAX_VEHICLE_ATTACHED_OBJECTS; Any++ )
if ( IsValidDynamicObject( p_Object[ playerid ][ Any ] ) )
DestroyDynamicObject( p_Object[ playerid ][ Any ] );
}
}
return ( 1 );
}
That's the only way to get rid of it. If the vehicle is created; therebefore it's valid, it'll do the rest of the code else not.
Re: Run time error 4: "Array index out of bounds" -
nGen.SoNNy - 02.11.2013
I didn't wanted to be rude. I just told that guy that my "dynamic design" it's ok and his type of scripting it's just basic. Thx for the answer i will rep you if i will finish this problem.
Re: Run time error 4: "Array index out of bounds" -
nGen.SoNNy - 03.11.2013
I changed that part and added some "debug" printf row and the result after some time is:
pawn Код:
[CarSpawner]: Invalid vehicle ID used on this function by: SoNNy(33) [Vehicle: 65535]
So this result it's caused by reaching the limit of 2000 vehicles. All vehicles create with that function and others will be destroyed OnPlayerDeath and OnPlayerDisconnect. I tried with no server vehicles on it but the same result...
EDIT: Something weird... the players that are conected since 3-4 hours are able to use the /car or /v command but the command it's starting to get fuc^#d up for the new players.
Re: Run time error 4: "Array index out of bounds" -
nGen.SoNNy - 03.11.2013
Somebody ?