I’m trying to figure out how to make it feel like an “instant taxi” on server-join. at this moment, I’ve gotten this to “work”
RegisterNUICallback(“spawnPlayer”, function(data)
local Location = data[“Location”]
SpawnPlayer(Location)
local player = GetPlayerPed(-1)
local vehicle = GetHashKey(“taxi”)
local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0, 5.0, 1)
RequestModel(0xC703DB5F)
while not HasModelLoaded(0xC703DB5F) do
Wait(1)
end
local car = CreateVehicle(vehicle, coords, 0.0, true, false)
SetPedIntoVehicle(player, car, 2)
end)
Problem is after it spawns the taxi, it resets my coord’s to 0,0,0, and fall through the map.
Not sure if @andreas_developing or someone had some insight on why it’s resetting to 0,0,0; or if i’m using the wrong Nui?
edit: even tried some playing around with the code, with no changes, but wanted to post it too.
RegisterNUICallback(“spawnPlayer”, function(data)
local Location = data[“Location”]
SpawnPlayer(Location)
local VehicleName = ‘Taxi’
RequestModel(0xC703DB5F)
while not HasModelLoaded(0xC703DB5F) do
Wait(3000)
end
local player = GetPlayerPed(-1)
local vehicle = GetHashKey(“taxi”)
–local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0, 5.0, 1)
local coords = GetEntityCoords(PlayerPed)
local car = CreateVehicle(vehicle, coords.x, coords.y, coords.z, GetEntityHeading(PlayerPed), true, false)
SetPedIntoVehicle(player, car, 2)
SetEntityAsNoLongerNeeded(vehicle)
SetModelAsNoLongerNeeded(VehicleName)
end)