Sign in to follow this  
zDxvilZ

Save cars in database

Recommended Posts

Hey Guys, 

I have a question. And if a player buys a car, how do I save it in the database

Thanks for your help!

Share this post


Link to post
Share on other sites

Have a vehicles table with all of the columns relating to the vehicles properties then a foreign key for the players unique ID (ex. OwnerID). To get the players vehicles just fetch all vehicles where the players unique ID (ID/GUID/Whatever) matches that unique ID on the vehicles table (OwnerID). To save a new vehicle to the database as mentioned above you'll have a vehicle table with the vehicle properties and it's just a matter of doing an INSERT/UPDATE query with the required data. There are other more detailed database design methods but this one is pretty universal. 

Share this post


Link to post
Share on other sites

And how do I „park“ the car?

That the car is right in front of me.

Thanks!

Share this post


Link to post
Share on other sites

Loop all vehicles and get the closest one to your player position. 

Take that car object and safe it to the database.

Share this post


Link to post
Share on other sites

add me on discord i can give you a example

 

discord : qdex#3223

  • Mask 1

Share this post


Link to post
Share on other sites
Posted (edited)

Can you add me on discord @qdex?

because i get an error that discord don't find your name

Fabio_#5860

Edited by zDxvilZ
  • Sad 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.