MySQL Vehicle Saving Issue
#2

Well first of all you're missing a comma in your update query after the model, which is causing the third error.

pawn Код:
format(queue, sizeof(queue), "UPDATE `Vehicles` SET VehicleOwner= '%s', Model= '%d', VehPosX= '%f', VehPosY= '%f', VehPosZ= '%f', VehRot= '%f', WHERE ID= '%d'", PlayerName(playerid), TheModelID, vehx, vehy, vehz, angle, VehicleID());
Second of all you're trying to fetch results without a query nevery happening? Not to mention you free the result and then call the store function again? It doesn't make any sense. I assume you're trying to achieve something like so:

pawn Код:
stock LoadBoughtVehicles(playerid)
{
    new row[999];
    new name[MAX_PLAYER_NAME];
    mysql_query("SELECT * FROM `Vehicles`"); // Do the query to select the data from the table
    mysql_store_result(); // Store all of the information
    while(mysql_fetch_row(row, "|")) // Format the information in the row variable with | as the delimiter
    {
        sscanf(row, "p<|>s[24]sdffff", name, VehicleData[playerid][VehicleOwner], VehicleData[playerid][Model], VehicleData[playerid][VehPosX], VehicleData[playerid][VehPosY], VehicleData[playerid][VehPosZ], VehicleData[playerid][VehRot]);
        CreateVehicle(VehicleData[playerid][Model], VehicleData[playerid][VehPosX], VehicleData[playerid][VehPosY], VehicleData[playerid][VehPosZ], VehicleData[playerid][VehRot], 1, 1,100);
    }
    mysql_free_result(); // We're done with all of the results, free the stored data and move on...
}
Read the comments in this code and it should make more sense. Also you can only use AddStaticVehicle in OnGameModeInit and OnFilterScriptInit, so you need to use something like CreateVehicle instead, which I replaced in that example code.

Hope that helps.
Reply


Messages In This Thread
MySQL Vehicle Saving Issue - by Unknown123 - 03.03.2011, 20:34
Re: MySQL Vehicle Saving Issue - by JaTochNietDan - 03.03.2011, 20:50
Re: MySQL Vehicle Saving Issue - by Unknown123 - 03.03.2011, 20:58
Re: MySQL Vehicle Saving Issue - by JaTochNietDan - 03.03.2011, 21:07
Re: MySQL Vehicle Saving Issue - by Unknown123 - 03.03.2011, 21:14
Re: MySQL Vehicle Saving Issue - by JaTochNietDan - 03.03.2011, 21:18
Re: MySQL Vehicle Saving Issue - by Unknown123 - 03.03.2011, 21:21
Re: MySQL Vehicle Saving Issue - by JaTochNietDan - 03.03.2011, 21:30
Re: MySQL Vehicle Saving Issue - by Unknown123 - 03.03.2011, 21:33

Forum Jump:


Users browsing this thread: 2 Guest(s)