[HELP] Spawn Vehicle

Hi,

I would like to spawn a Benson with the texture “Stay Frosty!”. I actually using this :

function SpawnVehicle(request)
	local myPed = GetPlayerPed(-1)
	local player = PlayerId()
	local vehicle = GetHashKey(request)

    RequestModel(vehicle)

	while not HasModelLoaded(vehicle) do
		Wait(1)
	end

	local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 5.0, 0)
	local spawned_car = CreateVehicle(vehicle, coords, 64.55118,116.613,78.69622, true, false)
	SetVehicleOnGroundProperly(spawned_car)
	SetPedIntoVehicle(myPed, spawned_car, - 1)
	SetModelAsNoLongerNeeded(vehicle)
end

But now I don’t know how to set the “Stay Frosty!” skin. Thanks :smiley:

I think you can spawn other models ?
If so, I think you stay into the while loop cause the model is wrong or not acceptable by FiveM

But how can i spawn the model ?

Is the function working with an other model ?

I just want to spawn the Benson with the texture Stay Frosty but i don’t know how to do this

After spawning the Vehicle you have to disable Vehicle extra 1 - 3 and 5 - 14 and only enable Vehicle Extra 4. Extra 4 is the “Stay Frosty” Livery.

SetVehicleExtra(vehicle, extraId, 0) --ON
SetVehicleExtra(vehicle, extraId, 1) --OFF
function SpawnVehicle(request)
	local myPed = GetPlayerPed(-1)
	local player = PlayerId()
	local vehicle = GetHashKey(request)

    RequestModel(vehicle)

	while not HasModelLoaded(vehicle) do
		Wait(1)
	end

	local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 5.0, 0)
	local spawned_car = CreateVehicle(vehicle, coords, 64.55118,116.613,78.69622, true, false)
	SetVehicleOnGroundProperly(spawned_car)
	SetPedIntoVehicle(myPed, spawned_car, - 1)
	SetModelAsNoLongerNeeded(vehicle)
	if IsVehicleModel(spawned_car, GetHashKey("BENSON")) then
		for i = 1, 14 do
			if DoesExtraExist(spawned_car, i) then
				SetVehicleExtra(spawned_car, i, 1)
			end
		end
		SetVehicleExtra(spawned_car, 4, 0)
	end
end
1 Like

Thanks you so much :smiley: but can you send me the link where you find the extraId ?

Just try them all, with a for

1 Like

I did not found it anywhere, I knew that the liverys are extras and just tried which is the correct one.

If you want to, you can use my modified version of the Scorpion Trainer. It contains Extra ON/ OFF Toggles to check which extraID is what.

Speaking of Extras, I though coffee cups and other little things were part of extras but I’m unable to spawn them.
I even tried to copy all extras (0-14) from an existing car with coffee near the dashboard to a new one (same model) and it’s not here.
I tried also to copy liveries, mods but I can’t get it to spawn…

@Bob_74
Do you mean covfefe cups on the dashboard? These are extras.

Yup coffee cups, I though they were extra since there tagged as so in ZModeler but I’m unable to spawn them…

With fakeveh.veh being an existing car with coffee cup and playerveh.veh the new car (same model, color, etc):

for i = 0, 14 do
	if DoesExtraExist(fakeveh.veh, i) then
		SetVehicleExtra(playerveh.veh, i, true)
	end
end

I don’t see where I’m doing something wrong.

I even tried to push extraId up to 48 just to see if something would pop up but nope.

You are using SetVehicleExtra wrong. true means OFF and false means ON.

1 Like

Omg you’re right!
This is so silly! Thank you so much!!

I don’t think I would have ever find out this aberration :sweat_smile:

1 Like

Haha I had the same problem and I know how annoying it can be

xPlayer.showNotification("¦~g~Ta ~y~5 Sanie ~g~Dg Ye Motor Braye Shoma Spawn Mishe.")
Wait(5000)
TriggerClientEvent('jc_carthief:spawnVehicle', _source, "bf400")

end)

(Can help. I would like to be given a car after 5 seconds after stealing and delivering the stolen car)