[HELP] Vehicle Spawn Direction/position

Hey there, me again :slight_smile:

i’m searching a way to turn the spawn direction of the vehicle i Spawn with this script :

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		DrawMarker(1, 2394.40, 4983.22, 44.21, 0, 0, 0, 0, 0, 0, 2.001, 2.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 0)
				
		if GetDistanceBetweenCoords(2394.40, 4983.22, 44.21, GetEntityCoords(LocalPed())) < 1 then
			drawTxt('Press ~g~H~s~ to spawn a  ~b~Truck', 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
			if IsControlJustPressed(1, Keys["H"]) then
				InitMenuHelico()
				Menu.hidden = not Menu.hidden
			end
		end
		Menu.renderGUI()
	end
end)


RegisterNetEvent('farmg:c_classic')
AddEventHandler('farmg:c_classic', function()
	Citizen.Wait(0)
	local myPed = GetPlayerPed(-1)
	local player = PlayerId()
	local vehicle = GetHashKey('trailers3')
	RequestModel(vehicle)
	while not HasModelLoaded(vehicle) do
		Wait(1)
	end
	local plate = math.random(100, 900)
	local coords = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0, 15.0, 0)
	local spawned_car = CreateVehicle(vehicle, coords, 2407.10864257813, 4958.5146484375, 44.6461868286133, true, false)
	SetVehicleOnGroundProperly(spawned_car)
	--SetPedIntoVehicle(myPed, spawned_car, - 1)
	SetModelAsNoLongerNeeded(vehicle)
	Citizen.InvokeNative(0xB736A491E64A32CF, Citizen.PointerValueIntInitialized(spawned_car))
end)

Any Idea on how i can turn the spawn or make a more sharp/exact spawn of vehicle ?

Thanks for help.

What you need to do is write the scrpt like this : CreateVehicle(vehicle,x,y,z,h…)
For example : CreateVehicle(vehicle, 2407.10864257813, 4958.5146484375, 44.6461868286133, 0.0…)
here the “0.0” is the heading, when you will spawn your car it will be turn to the NORTH.
You can change the value to turn your vehicle to another heading !

1 Like

Goin to try this now :slight_smile: Love You bro, thank you for your answer.

EDIt : Just perfect, thank you. You helped me a lot. /bow

1 Like

No problem, you’re welcome :slight_smile:

1 Like