25.08.2014, 21:45
Hi there, I've been having a little bit of problem loading my player vehicles...
My LoadPlayerCars code:
My Current problem is that whenever a player who owns a vehicle disconnects, he'll be the owner of the next player vehicle thats spawned. For example
Player A:
Buys Vehicle
Gets Assigned SecondV_ID(this is the variable used to create the car) 312
Gets Assigned V_ID(the vehicle id stored in the db for reference) 322
Disconnects
SecondV_ID is destroyed(despawned)
Player B:
Spawns with V_ID 325
Vehicle V_ID 325 loads into arrays
Vehicle V_ID 325 spawns with SecondV_ID 312(this is the bug)
Player B's vehicle owner is Player A.(obvious bug)
Thats the best i can explain, if you need clarification on anything please let me know. I really need help on this. It'll be Very grateful of you if you help.
I hope to get a reply fast.
My LoadPlayerCars code:
pawn Код:
stock LoadPlayerCars(carid)
{
new query[500];
format(query,sizeof(query),"SELECT * FROM vehicles WHERE `Vehicle_ID` = %d",carid);
mysql_query(query);
mysql_store_result();
new Results[256];
while(mysql_fetch_row(query))
{
mysql_fetch_field("Vehicle_ID",Results);
Vehicle[carid][V_ID] = strval(Results);
mysql_fetch_field("Model_ID",Results);
Vehicle[carid][Model] = strval(Results);
mysql_fetch_field("Owner",Vehicle[carid][Owner]);
mysql_fetch_field("Vehicle_Position", Results);
sscanf(Results, "ffff", Vehicle[carid][CarPosition][0], Vehicle[carid][CarPosition][1], Vehicle[carid][CarPosition][2],Vehicle[carid][CarPosition][3]);
mysql_fetch_field("Vehicle_Deal_Position", Results);
sscanf(Results, "ffff", Vehicle[carid][SpawnDealPosition][0], Vehicle[carid][SpawnDealPosition][1], Vehicle[carid][SpawnDealPosition][2],Vehicle[carid][SpawnDealPosition][3]);
mysql_fetch_field("Vehicle_Value", Results);
Vehicle[carid][Vehicle_Price] = strval(Results);
mysql_fetch_field("Color_ID_1", Results);
Vehicle[carid][Vehicle_Paint] = strval(Results);
mysql_fetch_field("Color_ID_2", Results);
Vehicle[carid][Vehicle_Paint2] = strval(Results);
Vehicle[carid][SecondV_ID] = CreateVehicle(Vehicle[carid][Model],Vehicle[carid][CarPosition][0], Vehicle[carid][CarPosition][1], Vehicle[carid][CarPosition][2],Vehicle[carid][CarPosition][3],Vehicle[carid][Vehicle_Paint],Vehicle[carid][Vehicle_Paint2],60000);
printf(" V_ID: %d | SecondV_ID: %d | Owner: %s | i= %d",Vehicle[carid][V_ID],Vehicle[carid][SecondV_ID],Vehicle[carid][Owner],carid);
}
}
Player A:
Buys Vehicle
Gets Assigned SecondV_ID(this is the variable used to create the car) 312
Gets Assigned V_ID(the vehicle id stored in the db for reference) 322
Disconnects
SecondV_ID is destroyed(despawned)
Player B:
Spawns with V_ID 325
Vehicle V_ID 325 loads into arrays
Vehicle V_ID 325 spawns with SecondV_ID 312(this is the bug)
Player B's vehicle owner is Player A.(obvious bug)
Thats the best i can explain, if you need clarification on anything please let me know. I really need help on this. It'll be Very grateful of you if you help.
I hope to get a reply fast.