mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
fix(resource/cache): skip cache updates during ped transitions (#28)
also fixes an issue with cache not being set correctly when weapon hash is a negative number
This commit is contained in:
committed by
GitHub
parent
753d3eb025
commit
9fbf0222ad
7
resource/cache/client.lua
vendored
7
resource/cache/client.lua
vendored
@@ -29,6 +29,9 @@ local GetCurrentPedWeapon = GetCurrentPedWeapon
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local ped = PlayerPedId()
|
||||
|
||||
-- If the player's ped is changed, the ped value may return 0 during the transition. If the value is 0, skip all checks.
|
||||
if ped ~= 0 then
|
||||
cache:set('ped', ped)
|
||||
|
||||
local vehicle = GetVehiclePedIsIn(ped, false)
|
||||
@@ -60,8 +63,8 @@ CreateThread(function()
|
||||
end
|
||||
|
||||
local hasWeapon, currentWeapon = GetCurrentPedWeapon(ped, true)
|
||||
|
||||
cache:set('weapon', hasWeapon and currentWeapon or false)
|
||||
cache:set('weapon', (hasWeapon and currentWeapon ~= 0) and currentWeapon or false)
|
||||
end
|
||||
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user