PDA

View Full Version : Vehicle System


homelessdrop
27/03/2019, 11:06 PM
Hello guys.
I have a question about making mysql based dynamic vehicle system. I know it is broad concept, but I don't know how to start this. I never did it because I don't understand how it works.
Thank you ahead for answer's.

(by the way sorry for my poor english).

introzen
28/03/2019, 08:25 AM
You could set it up in different ways, all according to your preference, but the basics of storing information in a database remains the same.

- You create a database and table to hold all vehicle information.
- You create something to hold all the vehicle data locally on the server. (E.g. VehicleInfo[MAX_VEHICLES][vInfo])
- Upon an event of your choosing, E.g. OnGameModeInit or if you want /spawncar etc., you load all information from the database into VehicleInfo where the first dimension (VehicleInfo[this]) will represent the vehicle's ID.
- Do whatever you want to the vehicle when it's spawned, but make sure to update VehicleInfo if any information stored there should change. Example of this could be to store the color and when you change it in-game you also update VehicleInfo to match it.
- When you're done, e.g. OnGameModeExit or on /despawncar, you save the information from each entry in VehicleInfo to the matching row in the database.

This is just a very general description of how it works. It all changes depending on how you want it to work and what functions are necessary.

homelessdrop
28/03/2019, 11:17 AM
Thank you @introzen for tips and ideas.
I hope, finally i make at least one normal vehicle system.