Closed Demigod916 closed 1 month ago
fix manason pls
AddEventHandler('qbx_core:server:onSetMetaData', function(key, _, new, source)
if key == 'hunger' or key == 'thirst' or key == 'stress' then
Player(source).state:set(key, new, true)
end
end)
nvm looks like the state is being synced in the self.Functions.SetMetaData. but still experiencing the desynced values between metadata and state for status. will work on a repro
local PlayerState = LocalPlayer.state
CreateThread(function ()
while true do
print("ON LOOP")
lib.print.info("STATE:", "HUNGER:", PlayerState.hunger)
lib.print.info("STATE:", "THIRST:", PlayerState.thirst)
lib.print.info("META:", "HUNGER:", QBX.PlayerData.metadata.hunger)
lib.print.info("META:", "THIRST:", QBX.PlayerData.metadata.thirst)
Wait(500)
print("========================================================")
end
end)
RegisterCommand('addhunger', function ()
TriggerServerEvent('consumables:server:addHunger', QBX.PlayerData.metadata.hunger + 1000) --- this event just sets the hunger using setMetaData function
end)
RegisterCommand('addthirst', function ()
TriggerServerEvent('consumables:server:addThirst', QBX.PlayerData.metadata.thirst + 1000)--- this event just sets the thirst using setMetaData function
end)
RegisterNetEvent('hud:client:UpdateNeeds', function (hunger, thirst)
print("ON UPDATE")
lib.print.info("STATE:", "HUNGER:", PlayerState.hunger)
lib.print.info("STATE:", "THIRST:", PlayerState.thirst)
lib.print.info("META:", "HUNGER:", QBX.PlayerData.metadata.hunger)
lib.print.info("META:", "THIRST:", QBX.PlayerData.metadata.thirst)
print("========================================================")
end)
here is a repro and then also i made a pr #459
Summary
hunger and thirst states desynced from metadata
Reproduction
Expected behavior
state and metadata synced for backwards compat.
Actual behavior
dies while hunger and thirst are not empty on hud using metadata
Additional context
assume that this can be fixed with a onMetaChange handler in the core
Current Version
v1.11.0
Custom Resources
.