Qbox-project / qbx_core

http://qbox-project.github.io
Other
45 stars 109 forks source link

Hunger level increments only after first burger #470

Open ArturMichalak opened 1 month ago

ArturMichalak commented 1 month ago

Summary

Metadata desynchronization problem still occurs, i think. Enforcing sychronization helps.

Reproduction

  1. Set hunger level to 10

  2. Buy 2 burgers in a shop

  3. Eat bought food

  4. No hunger bar update after eating second burger

  5. Set hunger level to 10

  6. Spawn 3 twerks candies /additem 1 twerks_candy 3

  7. Eat food

  8. Food level in admin menu does not update

Expected behavior

Update metadata on changes

Actual behavior

as in reproduction

Additional context

obraz

I made a hotfix in smallresources that partially fixes this, but the fix needs to be done qbx_core.

https://github.com/Qbox-project/qbx_smallresources/pull/99/files

Current Version

v1.12.0

Custom Resources

unreleased version of qbx_vehiclekeys

ArturMichalak commented 1 month ago

After some time there is synchronization, but not immediately.

TonybynMp4 commented 1 month ago

After some time there is synchronization, but not immediately.

So it works as expected, great.

ArturMichalak commented 1 month ago

10 burgers without affecting hunger level is expected?

TonybynMp4 commented 1 month ago

10 burgers without affecting hunger level is expected?

Hunger level ~= metadata

ArturMichalak commented 1 month ago

but are related Setting metadata solves the problem.

--- sets player hunger level in statebag
--- @param source number
--- @param amount number
local function setHunger(source, amount)
    amount = lib.math.clamp(amount, 0, 100)
    Player(source).state.hunger = amount

    --- hotfix
    local player = exports.qbx_core:GetPlayer(source)
    if not player then return end

    player.Functions.SetMetaData('hunger', amount)
    --- hotfix
end