15.04.2018, 14:26
Just add an 'ID' column with the auto-increment enabled to your table and set that as primary key.
Each time someone buys a vehicle, you just insert a new row into your database and MySQL will automatically increase the ID by 1, giving every vehicle a truely unique ID.
After inserting the new vehicle, use "cache_insert_id" to get the newly created ID for that vehicle and store it in your enum.
Note that this ID isn't the same as the ingame vehicleid used by all vehicle-functions.
It's only a value to reference the vehicle in the database, you can't use it with SAMP's vehicle-functions.
Vehicleid's ingame range from 1 to 1999, but the ID in your database goes from 1 to 2 billion.
Vehicleid's ingame will be re-used when a vehicle is removed from the world and re-created afterwards, the ID in the database will never be used again.
Each time someone buys a vehicle, you just insert a new row into your database and MySQL will automatically increase the ID by 1, giving every vehicle a truely unique ID.
After inserting the new vehicle, use "cache_insert_id" to get the newly created ID for that vehicle and store it in your enum.
Note that this ID isn't the same as the ingame vehicleid used by all vehicle-functions.
It's only a value to reference the vehicle in the database, you can't use it with SAMP's vehicle-functions.
Vehicleid's ingame range from 1 to 1999, but the ID in your database goes from 1 to 2 billion.
Vehicleid's ingame will be re-used when a vehicle is removed from the world and re-created afterwards, the ID in the database will never be used again.