28.05.2012, 04:10
Hey Everyone,
I'm working on a SQLite game mode. A friend of mine helped me with this SQLite Vehicle System. This script doesnt creates the table if it doesnt exist. So first of all i got it working , Now it Creates the table with the given Types of fields for the table. I made this new Column called "locked" and this new VehicleVar called "Vehicle[vehicleid][vLocked]"
Now the problem is. This array works fine in game. That means if this array is 0 then it will be zero also in game . I can lock a vehicle and see the printf which shows that this array is changed to 1 and then the SaveVehicle() is called , it saves the vehicles and printf's the Vehicle Vars. Lock is the same as it was in the database , i.e if it was zero then it will zero , if it was one then it will be one here. Vehicle Vars changes in the game but doenst save properly. They load just fine. But saving is the problem i dont know why.
Everything use to work fine before. But after adding this new column called "locked" and PVar "Vehicle[vehicleid][vLocked]" in the game mode. It doesnt save the lock variable , everything is stored and loaded just fine. Its just the problem with lock (Saving Not Loading)
My SaveVehicle(vehicleid) callback.
I'm working on a SQLite game mode. A friend of mine helped me with this SQLite Vehicle System. This script doesnt creates the table if it doesnt exist. So first of all i got it working , Now it Creates the table with the given Types of fields for the table. I made this new Column called "locked" and this new VehicleVar called "Vehicle[vehicleid][vLocked]"
Now the problem is. This array works fine in game. That means if this array is 0 then it will be zero also in game . I can lock a vehicle and see the printf which shows that this array is changed to 1 and then the SaveVehicle() is called , it saves the vehicles and printf's the Vehicle Vars. Lock is the same as it was in the database , i.e if it was zero then it will zero , if it was one then it will be one here. Vehicle Vars changes in the game but doenst save properly. They load just fine. But saving is the problem i dont know why.
Everything use to work fine before. But after adding this new column called "locked" and PVar "Vehicle[vehicleid][vLocked]" in the game mode. It doesnt save the lock variable , everything is stored and loaded just fine. Its just the problem with lock (Saving Not Loading)
My SaveVehicle(vehicleid) callback.
pawn Код:
public SaveVehicle(vehicleid)
{
if(VehicleExistsArray(vehicleid))
{
new array_id = VEHICLE_ARRAY_ID[vehicleid];
//printf("SV ARRAY_ID %d", array_id);
format(query, sizeof(query), "UPDATE `Vehicle` SET `x` = '%f', `y` = '%f', `z` = '%f', `model` = '%d', `color1` = '%d', `color2` = '%d', `angle` = '%f', `world` = '%d', `price` = '%d', `forsale` = '%d', `factionid` = '%d', `locked` = '%d', `owner_id` = '%d', `owned` = '%d' WHERE `id` = '%d'",
Vehicle[array_id][vX],
Vehicle[array_id][vY],
Vehicle[array_id][vZ],
Vehicle[array_id][vModel],
Vehicle[array_id][vColor1],
Vehicle[array_id][vColor2],
Vehicle[array_id][vAngle],
Vehicle[array_id][vWorld],
Vehicle[array_id][vPrice],
Vehicle[array_id][vForSale],
Vehicle[array_id][vFactionID],
Vehicle[array_id][vLocked],
Vehicle[array_id][vOwner_ID],
Vehicle[array_id][vOwned],
Vehicle[array_id][vSQLID]);
db_free_result(db_query(database,query));
printf("[VEH]%d (%d) saved. [%d|%d|%d|Lock:%d]", Vehicle[array_id][vSQLID], Vehicle[array_id][vID], Vehicle[array_id][vOwner_ID], Vehicle[array_id][vOwned], array_id, Vehicle[array_id][vLocked]);
}
return true;
}