Back to Main Page


Technical info about the Vehicle Spawn Factory mod. This is a minor service mod providing remote vehicle requesting and spawning for other mods.

 

Vehicle Spawn Factory - Vehicles On Demand


The Vehicle Spawn Factory is a service mod. What that means, is that its role is simply to provide a service to other mods. The service it provides, is to spawn vehicles into the world.

Because of the way the GTA V model requesting system normally works, you have to request a model, check if it exists and if not, request it again. This is to make sure your vehicle is spawned into the world properly. This can cause slight delays or stutters in your mod though, which can result in UI elements flickering off if the draw cycle is pushed over a frame. Mainly because SHVDN offers no multi-threading support of any kind.

So VSF sits in the background waiting for a request for a service ID. Mods use this ID to submit requests and to then identify the vehicles when the VehicleReady event is fired. Once a mod has an ID, it can then submit a request for a vehicle.

This is a simple struct with various vehicle details, the model, the location, the heading and because of my Courier Services mod, a livery setting as well. You can also specify if the vehicle is to be persistent or not. So the VSF requests the model, waits until it has been loaded, spawns the vehicle in the specified location and heading, sets the livery if specified and then fires off an event.

That's all it does. There's no UI, no interface of any kind, and no interaction with the user outside the requests from other mods. But what it does, is spawn vehicles into the world with no impact on the mod that needs the vehicle.

A mod can either submit a single request, or it can submit a collection of requests that will get queued and processed in turn.