mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 00: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": [
|
"Lua.diagnostics.globals": [
|
||||||
"MySQL",
|
"MySQL",
|
||||||
"GetPlayerTimeOnline"
|
"GetPlayerTimeOnline",
|
||||||
|
"SetEntityOrphanMode"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,10 +260,16 @@ AddStateBagChangeHandler("VehicleProperties", nil, function(bagName, _, value)
|
|||||||
error("Tried to set vehicle properties with invalid netId")
|
error("Tried to set vehicle properties with invalid netId")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local vehicle = NetToVeh(netId)
|
local vehicle = NetToVeh(netId)
|
||||||
if not DoesEntityExist(vehicle) then
|
|
||||||
error("Tried to set vehicle properties with invalid vehicle")
|
local tries = 0
|
||||||
return
|
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
|
end
|
||||||
|
|
||||||
if not NetworkGetEntityOwner(vehicle) == ESX.playerId then
|
if not NetworkGetEntityOwner(vehicle) == ESX.playerId then
|
||||||
|
|||||||
@@ -102,8 +102,9 @@ if not Config.Multichar then
|
|||||||
local playerId = source
|
local playerId = source
|
||||||
local identifier = ESX.GetIdentifier(playerId)
|
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
|
end
|
||||||
|
|
||||||
if oneSyncState == "off" or oneSyncState == "legacy" then
|
if oneSyncState == "off" or oneSyncState == "legacy" then
|
||||||
|
|||||||
@@ -93,19 +93,21 @@ function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
|
|||||||
if vehicleType then
|
if vehicleType then
|
||||||
local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords.x, coords.y, coords.z, heading)
|
local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords.x, coords.y, coords.z, heading)
|
||||||
local tries = 0
|
local tries = 0
|
||||||
while not DoesEntityExist(createdVehicle) do
|
|
||||||
|
while not createdVehicle or createdVehicle == 0 or not GetEntityCoords(createdVehicle) do
|
||||||
Wait(200)
|
Wait(200)
|
||||||
tries = tries + 1
|
tries = tries + 1
|
||||||
if tries > 10 then
|
if tries > 20 then
|
||||||
return print("[^1ERROR^7] Unfortunately, this vehicle has not spawned")
|
return error(("Could not spawn vehicle - ^5%s^7!"):format(model))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
SetEntityOrphanMode(createdVehicle, 2)
|
||||||
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
|
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
|
||||||
Entity(createdVehicle).state:set("VehicleProperties", vehicleProperties, true)
|
Entity(createdVehicle).state:set("VehicleProperties", vehicleProperties, true)
|
||||||
cb(networkId)
|
cb(networkId)
|
||||||
else
|
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)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user