05.05.2010, 21:12
You need to use while to continue executing, what your doing is only retrieving 1 (if any) result(s). Despite that, you unloaded the result too prematurely.
This will do the trick.
pawn Код:
public LoadCar()
{
new DataString[ 128 ], Query[ 128 ], idx;
format( Query, sizeof( Query ), "SELECT * FROM `Vehicles`");
mysql_query( Query );
mysql_store_result();
while( mysql_fetch_row_data() )
{
mysql_fetch_field( "CarID", DataString );
DynamicCars[ idx ][ CarID ] = strval( DataString );
mysql_fetch_field( "CarModel", DataString );
DynamicCars[ idx ][ CarModel ] = strval( DataString );
mysql_fetch_field( "CarX", DataString );
DynamicCars[ idx ][ CarX ] = strval( DataString );
mysql_fetch_field( "CarY", DataString );
DynamicCars[ idx ][ CarY ] = strval( DataString );
mysql_fetch_field( "CarZ", DataString );
DynamicCars[ idx ][ CarZ ] = strval( DataString );
mysql_fetch_field( "CarAngle", DataString );
DynamicCars[ idx ][ CarAngle ] = strval( DataString );
mysql_fetch_field( "CarColor1", DataString );
DynamicCars[ idx ][ CarColor1 ] = strval( DataString );
mysql_fetch_field( "CarColor2", DataString );
DynamicCars[ idx ][ CarColor2 ] = strval( DataString );
mysql_fetch_field( "FactionCar", DataString );
DynamicCars[ idx ][ FactionCar ] = strval( DataString );
mysql_fetch_field( "CarType", DataString );
DynamicCars[ idx ][ CarType ] = strval( DataString );
CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);
idx++;
}
mysql_free_result();
return 1;
}