[help] vehicle spawn

Sorry if my English is bad.

How do I make the script work to spawn vehicles from item usage?

for example: i have item “blista” in inventory, when i use it, it will spawn vehicle “blista”.

Please help.
Thank you for taking the time for me

Did you get the info how? Im also looking for this script :pray: thank you

Wow this topic is old!
But since it got revived because you need this functionality as well, here…

For ESX, you could probably just do this;

server.lua:

ESX.RegisterUsableItem("blista", function(source)
	local src = source
	local xPlayer = ESX.GetPlayerFromId(src)
	xPlayer.removeInventoryItem("blista", 1)
	TriggerClientEvent("spawnVehicleItemUsed", src, "blista")
end)

client.lua:

RegisterNetEvent("spawnVehicleItemUsed", function(model)
	local ped = PlayerPedId()
	local coords = GetOffsetFromEntityInWorldCoords(ped, 0.0, 3.0, 0.0)
	ESX.Game.SpawnVehicle(model, coords, GetEntityHeading(ped) - 90, function(vehicle)
		print(model .. " spawned!")
	end)
end)
1 Like

Thank you sir :pray: