mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 17:28:53 +00:00
fix: wait for vehicle on server instead of client
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user