[MySQL] Loading Vehicles
#4

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.

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;
}
This will do the trick.
Reply


Messages In This Thread
[MySQL] Loading Vehicles - by Agent Smith - 05.05.2010, 19:39
Re: [MySQL] Loading Vehicles - by woot - 05.05.2010, 20:56
Re: [MySQL] Loading Vehicles - by Agent Smith - 05.05.2010, 21:10
Re: [MySQL] Loading Vehicles - by Calgon - 05.05.2010, 21:12
Re: [MySQL] Loading Vehicles - by Agent Smith - 05.05.2010, 21:14

Forum Jump:


Users browsing this thread: 3 Guest(s)