Vehicle ID's Loading in random order. MySQL R41
#7

CarData has size of say MAX_VEHICLES. What you can do is store the data in local variables:
pawn Код:
cache_get_value_name_int(i, "carID", car_ID);
cache_get_value_name_int(i, "carModel", car_Model);
cache_get_value_name_int(i, "carOwner", car_Owner);
cache_get_value_name_float(i, "carPosX", car_Pos[0]);
cache_get_value_name_float(i, "carPosY", car_Pos[1]);
cache_get_value_name_float(i, "carPosZ", car_Pos[2]);
cache_get_value_name_float(i, "carPosR", car_Pos[3]);
cache_get_value_name_int(i, "carColor1", car_Color1);
cache_get_value_name_int(i, "carColor2", car_Color2);
...
and then create the vehicle
pawn Код:
new created_vehicle = CreateVehicle(car_Model, car_Pos[0], car_Pos[1], car_Pos[2], car_Pos[3], car_Color1, car_Color2, respawn_delay_here, siren_here..);
pawn Код:
if (created_vehicle != INVALID_VEHICLE_ID) // not reached limit or invalid modelid
{
    //assign vehicleid as index
    CarData[created_vehicle][carID] = car_ID;
    CarData[created_vehicle][carModel] = car_Model;
    ...
}
so now anything related to vehicle in-game as to what player is currently in, you can use the index to retrieve data from it. However, when you want to save the said vehicle:
pawn Код:
"UPDATE ... SET ... WHERE carID=%d", ..., CarData[iteration_variable_here][carID]);
And do not store components in the same table, use a different table (child) and carID will be the FOREIGN KEY: https://sampforum.blast.hk/showthread.php?tid=420363
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)