fix: wait for vehicle on server instead of client

This commit is contained in:
Mycroft
2022-08-11 18:23:13 +01:00
parent 6d5095cf9c
commit ef8fde3026
2 changed files with 6 additions and 10 deletions
-9
View File
@@ -489,15 +489,6 @@ function ESX.Game.SpawnVehicle(vehicle, coords, heading, cb, networked)
print("Spawned Vehicle: " .. NetID)
if NetID then
local vehicle = NetworkGetEntityFromNetworkId(NetID)
local Tries = 0
while not DoesEntityExist(vehicle) do
vehicle = NetworkGetEntityFromNetworkId(NetID)
Wait(0)
Tries += 1
if Tries > 250 then
break
end
end
SetEntityAsMissionEntity(vehicle, true, true)
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
SetVehicleNeedsToBeHotwired(vehicle, false)
+6 -1
View File
@@ -66,8 +66,13 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, autoMobile, cb)
if type(autoMobile) ~= 'boolean' then
return
end
local tries = 0
local Entity = autoMobile and Citizen.InvokeNative(`CREATE_AUTOMOBILE`, model, coords.x, coords.y, coords.z, heading) or CreateVehicle(model, coords, heading, true, true)
cb(NetworkGetNetworkIdFromEntity(Entity))
while not DoesEntityExist(Entity) do
Wait(0)
end
local netID = NetworkGetNetworkIdFromEntity(Entity)
cb(netID)
end
---@param model number|string