mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 21:01:20 +00:00
!tweak(es_extended): another attempt to mitigate vehicle creation issues
Note: this increases the Minimum Artifact to 10188
This commit is contained in:
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"Lua.diagnostics.globals": [
|
||||
"MySQL",
|
||||
"GetPlayerTimeOnline"
|
||||
"GetPlayerTimeOnline",
|
||||
"SetEntityOrphanMode"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -260,10 +260,16 @@ AddStateBagChangeHandler("VehicleProperties", nil, function(bagName, _, value)
|
||||
error("Tried to set vehicle properties with invalid netId")
|
||||
return
|
||||
end
|
||||
|
||||
local vehicle = NetToVeh(netId)
|
||||
if not DoesEntityExist(vehicle) then
|
||||
error("Tried to set vehicle properties with invalid vehicle")
|
||||
return
|
||||
|
||||
local tries = 0
|
||||
while not NetworkDoesEntityExistWithNetworkId(vehicle) do
|
||||
Wait(200)
|
||||
tries = tries + 1
|
||||
if tries > 20 then
|
||||
return error(("Invalid entity - ^5%s^7!"):format(netId))
|
||||
end
|
||||
end
|
||||
|
||||
if not NetworkGetEntityOwner(vehicle) == ESX.playerId then
|
||||
|
||||
@@ -102,8 +102,9 @@ if not Config.Multichar then
|
||||
local playerId = source
|
||||
local identifier = ESX.GetIdentifier(playerId)
|
||||
|
||||
if not GetPlayerTimeOnline then
|
||||
return deferrals.done(("[ESX] ESX Requires a minimum Artifact version of 9515, Please update your server."):format(oneSyncState))
|
||||
|
||||
if not SetEntityOrphanMode then
|
||||
return deferrals.done(("[ESX] ESX Requires a minimum Artifact version of 10188, Please update your server."):format(oneSyncState))
|
||||
end
|
||||
|
||||
if oneSyncState == "off" or oneSyncState == "legacy" then
|
||||
|
||||
@@ -93,19 +93,21 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
|
||||
if vehicleType then
|
||||
local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords.x, coords.y, coords.z, heading)
|
||||
local tries = 0
|
||||
while not DoesEntityExist(createdVehicle) do
|
||||
|
||||
while not createdVehicle or createdVehicle == 0 or not GetEntityCoords(createdVehicle) do
|
||||
Wait(200)
|
||||
tries = tries + 1
|
||||
if tries > 10 then
|
||||
return print("[^1ERROR^7] Unfortunately, this vehicle has not spawned")
|
||||
if tries > 20 then
|
||||
return error(("Could not spawn vehicle - ^5%s^7!"):format(model))
|
||||
end
|
||||
end
|
||||
|
||||
SetEntityOrphanMode(createdVehicle, 2)
|
||||
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
|
||||
Entity(createdVehicle).state:set("VehicleProperties", vehicleProperties, true)
|
||||
cb(networkId)
|
||||
else
|
||||
print(("[^1ERROR^7] Tried to spawn invalid vehicle - ^5%s^7!"):format(model))
|
||||
error(("Tried to spawn invalid vehicle - ^5%s^7!"):format(model))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user