mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 15:01:26 +00:00
refactor(es_extended/client/main.lua): VehicleProperties better way
This commit is contained in:
@@ -163,23 +163,29 @@ AddEventHandler('esx:restoreLoadout', function()
|
||||
end)
|
||||
|
||||
AddStateBagChangeHandler('VehicleProperties', nil, function(bagName, key, value)
|
||||
if value then
|
||||
Wait(0)
|
||||
local NetId = value.NetId
|
||||
local Vehicle = NetworkGetEntityFromNetworkId(NetId)
|
||||
local Tries = 0
|
||||
while Vehicle == 0 do
|
||||
Vehicle = NetworkGetEntityFromNetworkId(NetId)
|
||||
Wait(100)
|
||||
Tries = Tries + 1
|
||||
if Tries > 300 then
|
||||
break
|
||||
end
|
||||
end
|
||||
if NetworkGetEntityOwner(Vehicle) == PlayerId() then
|
||||
ESX.Game.SetVehicleProperties(Vehicle, value)
|
||||
end
|
||||
if not value then
|
||||
return
|
||||
end
|
||||
|
||||
local netId = bagName:gsub('entity:', '')
|
||||
local timer = GetGameTimer()
|
||||
while not NetworkDoesEntityExistWithNetworkId(tonumber(netId)) do
|
||||
Wait(0)
|
||||
if GetGameTimer() - timer > 10000 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local vehicle = NetToVeh(tonumber(netId))
|
||||
local timer = GetGameTimer()
|
||||
while NetworkGetEntityOwner(vehicle) ~= PlayerId() do
|
||||
Wait(0)
|
||||
if GetGameTimer() - timer > 10000 then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
ESX.Game.SetVehicleProperties(vehicle, value)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setAccountMoney')
|
||||
|
||||
Reference in New Issue
Block a user