For the complete documentation index, see llms.txt. This page is also available as Markdown.

Client State Bags

Getting Current Status

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_NAME
Example Usage
local 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 .. '%')

Listening for Status Changes

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)
Example Usage
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