01.11.2013, 16:39
Hello guys. I don't know why but on my server after 5-6 hours, when someone try to take a vehicle with /car command that will crash:
I tried to remove all the vehicles from the server and the private vehicles so the vehicles from server will be spawned just with /car command but nothing works. I don't fuc%!@ know what to do...
pawn Код:
[18:41:44] [debug] Run time error 4: "Array index out of bounds"
[18:41:44] [debug] Accessing element at index 65535 past array upper bound 1999
pawn Код:
CMD:car( playerid, params[ ] )
{
new
Car[ 30 ],
Color[ 2 ]
;
if ( sscanf( params, "s[30]D(-1)D(-1)", Car, Color[ 0 ], Color[ 1 ] ) )
return SendClientMessage( playerid, COLOR_ULTRARED, "USAGE: {33CCFF}/car [Name/Model] [Color1] [Color2]" );
if ( IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You are already in a vehicle!" );
new sCarModel;
if ( IsNumeric( Car ) )
sCarModel = strval( Car );
else
sCarModel = GetVehicleModelIDFromName( Car );
if ( sCarModel < 400 || sCarModel > 611 )
return SendError( playerid, "Invalid vehicle model/name!" );
if ( Color[ 0 ] == -1 )
Color[ 0 ] = random( 250 );
if ( Color[ 1 ] == -1 )
Color[ 1 ] = random( 250 );
if ( PlayerInfo[ playerid ][ pCar ] != -1 )
CarDeleter( PlayerInfo[ playerid ][ pCar ] );
new Float:cPos[ 4 ], LVehicleID, int1;
GetPlayerPos( playerid, cPos[ 0 ], cPos[ 1 ], cPos[ 2 ] );
GetPlayerFacingAngle( playerid, cPos[ 3 ] );
int1 = GetPlayerInterior( playerid );
LVehicleID = AddStaticVehicleEx( sCarModel, cPos[ 0 ]+3, cPos[ 1 ], cPos[ 2 ], cPos[ 3 ], Color[ 0 ], Color[ 1 ], -1 );
LinkVehicleToInterior( LVehicleID, int1 );
SetVehicleNumberPlate( LVehicleID, ""R"S"W"tun"O"T" );
SetVehicleVirtualWorld( LVehicleID, GetPlayerVirtualWorld( playerid ) );
PutPlayerInVehicle( playerid, LVehicleID, 0 );
PlayerInfo[ playerid ][ pCar ] = LVehicleID;
DestroyNeons( playerid );
for ( new Any = 0; Any < MAX_VEHICLE_ATTACHED_OBJECTS; Any++ )
if ( IsValidDynamicObject( p_Object[ playerid ][ Any ] ) )
DestroyDynamicObject( p_Object[ playerid ][ Any ] );
FormatMSG( playerid, ~1, "You have spawned a \"{FF9900}%s"W"\" {FF0000}(Model: %d). "W"Colors {FF9900}(%d, %d)", vNames[ sCarModel-400 ], sCarModel, Color[ 0 ], Color[ 1 ] );
return ( 1 );
}
public OnPlayerDisconnect( playerid, reason )
{
if ( PlayerInfo[ playerid ][ pCar ] != -1 )
CarDeleter( PlayerInfo[ playerid ][ pCar ] );
}