Making "server-side" cars, is it possible?

Hey everyone, I am new to FiveM. Been doing some research on how to get some cars to spawn at certain places in the map server-side, for example so that players could go to a drift map and just pick out a car they want without something like a vMenu. From reading the forums, it seems like the cars are made client-side and when players disconnect, spawned cars disappear. I just wanted to make sure what I have in mind is doable and I don’t shoot myself in the foot by doing a lot of work and then finding out it wasn’t possible to begin with. Here’s what I have in mind right now:

  1. Spawning the cars, when the first player connects to the server
    Client-side: When a player connects check to see if the player is alone, if so send a message to the server to “SpawnVehicles” (Because we want only 1 of each car, that are supposed to be “server-side”)
    Server-side: Then the server will have stored coordinates of vehicles and send a message back to the client to create mission entity vehicles at designated spots

What would be a good place to perform this operation?

  1. Do a respawn of the car at the designated space, after a player has exited the car, after X amount of time

  2. Do a respawn of the car after it is destroyed

How could I check when the car is destroyed? I tried a game event called: “CEventNetworkVehicleUndrivable” , with no success. Does it get called when only a player is sitting in the car? Also what parameters does it have? Is this Client-Side?

Also is there a limit on how many vehicles I can spawn?

If anyone could pitch in if this would be possible for me to make, that would be awesome!

1 Like

You could potentially try using DoesEntityExist - FiveM Natives @ Cfx.re Docs to determine whether the entity still exists? Just send the entity handle with the server event ‘SpawnVehicles’, and store it in a table then in a loop you can check whether the entity still exists with this and if it doesn’t respawn it? (Not tested, simply a theory).

I certainly don’t believe so.

1 Like

You’re probably looking for a vehicle generator. There’s a native for those but you can also make them from a #map file.

1 Like

Yep, I was going to suggest, the easiest way would be to just use Codewalker and create a vehicle generator at whatever location you want to set it up at. Then just stream that ymap with the vehicle generators.

1 Like

I don’t know how I missed the vehicle generators. I will give them a shot and see how that goes. Thank you!