Spawning cars at 'static locations'

Hey there guys,

Just “quick question”:
In my SA-MP server in the past I’ve had a vehicle streamer which i could use to stream “virtually”
as much vehicles on static spawn locations. The Vehicle streamer would keep track of which vehicles
which was recently taken/in use (and thus not instantly respawning it etc).

It there such a method available already for FiveM or even native wise?

Basic EXAMPLE explanation:
I want to build an trucker mission with several objectives depending on the trailer,
so i would like to spawn about 4 packers on default locations and several different trailers to pick up
on other locations.

Is there a way i could add these vehicles to a list, a spawn generator etc?
i had found after many reading and attempts of others:

But that doesn’t do the trick, it WILL spawn the cars when i place some test vehicles (including all
parameters), BUT once i leave the area and return they will just never respawn.

If it’s not possible in some sort of way i will have to make a simplified version of my SA-MP
vehicle spawn streamer which will just create a small delay to respawning them if another player
also enters the area (to keep it a bit more realistic and not like an “infinite re-spawn resource”.

It would not be a problem to make such a streamer, although if it’s not necessary since I just keep
overlooking options that are already available which would not just save me time but also server
traffic then that would be a massive waste of time and server resources of course :wink:

So if anyone knows a decent working and not server (network) traffic intensive method which
is already available then please give me some pointer where to look for :slight_smile:

Thanks in advance,
VenomXNL

1 Like

Just a random thought since i haven’t worked with map editing (or had the need for it),
but would it be possible to make ymap’s to place static vehicles? since for what i can
see now from the research i’ve done, entity’s are also ‘spawned/placed’ by Ymap’s in interiors and such.

Although i SUSPECT it would cause an problem like not syncing the vehicle to other clients if i’m correct right? since i do know from interior scripts i’m currently working on that lots of the interior props are not synced on kicking them away or on destruction.

Okay i have seen a ‘option here and there’ by now and investigated their codes, but most just spawn vehicles on player connect/spawn and make them persistent or even mission entity’s.

This is definitely not how it should be done obviously and far for good practice while keeping resources in mind if you ask me (OR GTA V must handle this differently internally with it’s "own streamer’ but i don’t suspect it to tbh).

Can anyone tell me if there will be an issue when setting (to many) items as Mission Entity? I suppose it will though since we encounted this during testing of the train script when spawning multiple trains (LOTS of them) which where set as mission entity, BUT of course this could also related to the ‘native background’ (what the game does behind the screens) with the train script(s)

Although it still doesn’t seem ‘healthy’ to me to use vehicles as mission entity to much
since that will also be (partially?) synced to other players, so even on leaving it would
create a mess on the server eventually i suspect?

Sorry for the late response - You’d have to create a variable for EACH static location (along with a heading), and you can then create a function that iterates over each variable (static location) to see if it’s empty, and then spawns something there;

You can ALSO (as an alternative) have the entity spawn in each static location, and call the spawn function for EACH variable and have it check in every 30 seconds to see if there’s a car there, and if not, then call the respawn function!

Still working on getting comfortable with the capabilities of LUA, so I don’t know quite how to translate this into source, but hopefully someone here can!

Have you tried this mod? It works pretty great and I think it uses SetVehicleHasBeenOwnedByPlayer and SetNetworkId to make sure cars don’t despawn, if you have a script in place that prevents that.

I use codewalker to find the ymap for a cargen near the location I want to place a vehicle, copy-paste said cargen, change the coords/orientation after finding them using a trainer, and then stream the ymap. Works fine for me & friends that join!