Client State Bags
Last updated
Returns the player's current status directly from the client state bag. These values are automatically synchronized by VMS Needs and are available at any time on the client.
LocalPlayer.state.STATUS_NAMElocal hunger = LocalPlayer.state.hunger
print('My hunger level is ' .. hunger .. '%')
local thirst = LocalPlayer.state.thirst
print('My thirst level is ' .. thirst .. '%')
local stress = LocalPlayer.state.stress
print('My stress level is ' .. stress .. '%')Registers a callback that is automatically executed whenever the selected state bag value changes. Recommended for HUDs, UI elements, and any system that needs to react to status changes in real time.
local serverId = GetPlayerServerId(PlayerId())
AddStateBagChangeHandler(STATUS_NAME, ("player:%s"):format(serverId), function(_, _, percentage)
print('Updated status to ' .. percentage .. '%')
end)local serverId = GetPlayerServerId(PlayerId())
AddStateBagChangeHandler("hunger", ("player:%s"):format(serverId), function(_, _, percentage)
-- Update HUD
end)
AddStateBagChangeHandler("thirst", ("player:%s"):format(serverId), function(_, _, percentage)
-- Update HUD
end)
AddStateBagChangeHandler("stress", ("player:%s"):format(serverId), function(_, _, percentage)
-- Update HUD
end)Last updated