Giter Site home page Giter Site logo

Comments (4)

Demigod916 avatar Demigod916 commented on August 18, 2024

fix manason pls

from qbx_core.

Demigod916 avatar Demigod916 commented on August 18, 2024
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)

from qbx_core.

Demigod916 avatar Demigod916 commented on August 18, 2024

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

from qbx_core.

Demigod916 avatar Demigod916 commented on August 18, 2024
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

from qbx_core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.