Skip to content

Commit

Permalink
Merge pull request #1553 from Mycroft-Studios/better-vehicle-spawning
Browse files Browse the repository at this point in the history
fix(es_extended/server/onesync): better vehicle spawning method
  • Loading branch information
Kenshiin13 authored Dec 16, 2024
2 parents afdbee3 + c32d674 commit c26b5d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions [core]/es_extended/server/modules/onesync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords.x, coords.y, coords.z, heading)
local tries = 0

while not createdVehicle or createdVehicle == 0 or not GetEntityCoords(createdVehicle) do
while not createdVehicle or createdVehicle == 0 or NetworkGetEntityOwner(createdVehicle) == -1 do
Wait(200)
tries = tries + 1
if tries > 20 then
if tries > 40 then
if promise then
return promise:reject(("Could not spawn vehicle - ^5%s^7!"):format(model))
end
Expand All @@ -122,6 +122,7 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
SetEntityOrphanMode(createdVehicle, 2)
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
Entity(createdVehicle).state:set("VehicleProperties", vehicleProperties, true)

if promise then
promise:resolve(networkId)
elseif cb then
Expand Down

0 comments on commit c26b5d7

Please sign in to comment.