[Release] Boot Vehicles v1.3 - Persistent Configured Vehicles!

I can only get vehicles to spawn with DEBUG is true and I use the command gvpos_trigger. When I set DEBUG to false nothing spawns.

if i remember correctly i did figure out the multiple spawning issue was due to something along the lines of the the vehicles being called twice for some reason??? i cant really remember now… ill go look for the script. i no longer use it but im pretty sure i did get that part fixed. ill post back here in a little bit with the fix for multiple spawns.

edit: Scratch that. I didnt want to forget to come back and post the fix so im doing it now while i have the time so here it is and its insanely simple and easy to miss so i see how it happened to all of us but first im sorry ahead of time for how long this repIy might be before im done.

Anyway i remember getting frustrated as heck for almost an hour while repeating the setup process a few times and getting either the same double spawns or even more after each attempt, up to like 10 of the same vehicle before I realized the problem is in the “__resource.lua” file which is shown just below. (at the very bottom is a copy of my entire resource file)

boot_vehicle_file ‘vehicle_positions.txt’ <<<----- this line MUST be commented out or the coordinates totally removed/deleted from vehicle_positions.txt ( DO NOT DELETE THE “vehicle_positions.txt” FILE ITSELF OR THE SCRIPT WILL BREAK!!) This only has to be done IF you are using the boot_vehicle_file section that comes below that file, meaning you have created new boot files and pasted the coords into them. The above mentioned file left unaltered will contain ALL of the coords you have captured that are needed for use in the creation of each boot_vehicle_file for whatever vehicle’s you choose, however the problem is the resource is currently being told to load the “vehicle_positions.txt” file AND all of the created “boot_vehicle_files” which means its loading them twice or more depending on how many times you captured the same coords for a particular location or locations.

My personal suggestion is simply comment out the (boot_vehicle_file ‘vehicle_positions.txt’) because there is simply no need to load this file as that is what the ones you create are for. Just be sure you do NOT delete “vehicle_positions.txt” and to make things easier always cut and paste when getting the new coordinates for a new boot vehicle otherwise it will get really cluttered and confusing in the “vehicle_positions.txt” file. Below is my resource file to use as an example that is fixed.

resource_manifest_version ‘679-996150c95a1d251a5c0c7841ab2f0276878334f7’
description ‘Boot Vehicles’

–boot_vehicle_file ‘vehicle_positions.txt’

– Add more files in your “vehicles” file and add them here
– You can remove the default examples by commenting them out (adding – at the start)
– boot_vehicle_file ‘vehicles/secret.txt’
–boot_vehicle_file ‘vehicles/mission_row.txt’
boot_vehicle_file ‘vehicles/merryweather.txt’
boot_vehicle_file ‘vehicles/noose.txt’
boot_vehicle_file ‘vehicles/chin_carr.txt’
boot_vehicle_file ‘vehicles/lola.txt’

server_scripts {
‘sv_bootvehicles.lua’,
‘version.lua’
}

client_scripts {
‘cl_bootvehicles.lua’
}

my last post should also help you because i encountered that as well and the script itself is not the problem. its all caused by the way the resource file is setup

When I use that resource file, the script doesn’t even load. Anyway I’m able to get the resource to load is with DEBUG in true and I have to trigger them to spawn.

Anyone have an idea?

I stoped to use this script (really nice ideas inside) 'cause use file make lags and when you had few players on your servers they crash…

I made a script that’s using database instead, i’m working on solve the problem of duplication (when 2nd players connect or same player re-connect).

One of the axis will be to detect if the cars is already spawn, other is to call spawn function at the start of the server. I worked on other script since my last message but now i’m back on this one.

If someone had a solution on a script called one time at the server boot ^^

1 Like

how did your script turn out? and have you made any progress with this one?

I guess this is no longer mainained, but i was wonedring if anyone could help me out a bit. The script seems to work nicely except on custom cars the extras are not saved correctly. Any tips on how to get the cars spawn with the extras i need?

I’m still having the problem with cars spawning for every player and not just one car for the server in a given location. Nothing like driving by a dealership and seeing a literal pile of spawned cars crammed inside it.

Kamranos,

I managed to get this fixed with the following:

At the very bottom of cl_bootvehciles.lua you will find:

AddEventHandler("playerSpawned", function(spawnInfo)
  if GetNumberOfPlayers() == 1 then
    TriggerServerEvent("collectVehicles")
  end
end)

Replace it with:

local FirstSpawn = true -- Global 
AddEventHandler(
  "playerSpawned",
  function(spawnInfo)
    if FirstSpawn and GetNumberOfPlayers() == 1 then
      FirstSpawn = false
      TriggerServerEvent("collectVehicles")
Citizen.Trace("Yea first player connected to instance. Creating environment!\n")
   
    end
     
  end
)

This seems to stop the cars from spawning every time a new player joins or respawns.

The problem I am having now is that vehicles do not spawn with the color i saved them as. They always spawn with whatever the default color of the car is. I tried messing with the code but the only thing i could achieve is all cars spawning black.

I want to either:
A) have the boot vehicles script save the color and spawn it with the same color on server reboot
or
B) Forget about the boot vehilce script handling the colors and just change the default color of addon vehicles to my desired color so when they spawn in via boot vehicles script, they are already the color i want them

I have a addon Mclaren F1 that is just always blue. I tried messing with the carvariations file but it seems to have no effect.

I tried your replacement and it still added more vehicles the next time someone spawned in, is there a way to check to see if spot is blocked before spawning again and again

It´s dont work by me when next user join cars double again. It is no Persisten Script i´m log out cars away
when im trigger alone Cars away im log off.

adding this to the top of sv_bootvehicles.lua

local vehiclesspawned = false

and replacing this function in sv_bootvehicles.lua

Citizen.CreateThread(function()
    RegisterServerEvent("collectVehicles")
    AddEventHandler("collectVehicles", function()
        local _source = source
        TriggerClientEvent("receivedVehicles", _source, vehicleSets)
    end)
end)

with this

Citizen.CreateThread(function()
    RegisterServerEvent("collectVehicles")
    AddEventHandler("collectVehicles", function()
        if vehiclesspawned == false then
			local _source = source
			TriggerClientEvent("receivedVehicles", _source, vehicleSets)
			vehiclesspawned = true
		end
    end)
end)

solved the issue of vehicles duplicating when a new player joined the server.

1 Like

Are we able to have the vehicles locked? I would like to have police cars spawned at stations but do not want them to be free game