[Issue]

When my players and i are playing on the server, the vehicles they spawned in, they randomly delete at random times. I did not create a script to alter the spawning, or deleting of vehicles. If anyone can help me diagnose this, i will be very appreciative. Thanks.

Sounds like this Player Vehicles Randomly Despawning

Yes it is the same issue, im assuming its our mellotrainer not setting vehicles saved to that player.

I don’t use mellotrainer

Hmmm. There must be some way to set our vehicles to not despawn globally. Maybe something like vSync but for cars.

Are you vehicles deleting when near/in them, or when far away?

My players are driving them and they delete. And someone said when one was near it deleted.

Set the vehicles as mission entities or the game might despawn them at random times

So something like this?

THIS WAS FROM CL_VEHICLES IN MELLOTRAINER

local function _SetEntityAsNoLongerNeeded(entity)
	Citizen.InvokeNative(0xB736A491E64A32CF,Citizen.PointerValueIntInitialized(entity))
end

local lastVehicle

local function SpawnVehicle(model, x, y, z, heading, ped)

	-- Just in case they are in a vehicle which this trainer didn't spawn.
	

	if IsModelValid(model) then
		_LoadModel( model )

		local veh = CreateVehicle( model, x, y, z + 1, heading, true, true )

		if featureSpawnInsideCar then
			SetPedIntoVehicle(ped, veh, -1)
			SetEntityAsMissionEntity()
		end

		if featureDeleteLastVehicle then
			_SetEntityAsNoLongerNeeded(veh)
			-- Remove the last vehicle.
			if (lastVehicle) then
				if(GetVehicleNumberOfPassengers(lastVehicle) ~= 0 or IsVehicleSeatFree(lastVehicle, -1) == false) then
					drawNotification("~r~Last Vehicle could not be deleted.")
				else
					SetEntityAsMissionEntity(lastVehicle, true, true)
					DeleteVehicle(lastVehicle)
				end
			end
		end

		drawNotification("~g~Vehicle spawned!")
		lastVehicle = veh
		UpdateVehicleFeatureVariables( veh )
		toggleRadio(ped)
		SetEntityAsMissionEntity()
		SetModelAsNoLongerNeeded( veh )

		return veh 
	else
		drawNotification("~r~Invalid Model!")
	end
end