# Events (/docs/orbit-studios-resources/orbit-dynamichud-stress/events)



# Events [#events]

Stress is stored as a replicated state bag value from 0 to 100.

Use the server events when you want the stress resource to handle clamping and whitelist checks. Read the state bag when you only need to display or react to the current value.

```lua title="resources/[custom]/client/main.lua"
local stress = LocalPlayer.state.stress or 0
```

```lua title="resources/[custom]/server/main.lua"
local src = source
local stress = Player(src)?.state?.stress or 0

Player(src)?.state:set("stress", 25, true)
```

<TypeTable
  type="{
  'hud:server:InitializeStress': {
    type: 'server event',
    description: 'Initializes player stress state when the client resource starts.',
  },
  'hud:server:GainStress': {
    type: 'server event',
    description: 'Adds stress, checks whitelisted jobs, and clamps the value to 100.',
  },
  'hud:server:RelieveStress': {
    type: 'server event',
    description: 'Removes stress and clamps the value to 0.',
  },
}"
/>

## Client Integration [#client-integration]

```lua title="resources/[custom]/client/main.lua"
TriggerServerEvent('hud:server:GainStress', 10)
TriggerServerEvent('hud:server:RelieveStress', 15)
```

Use client triggers for gameplay actions that happen locally, such as a minigame failure, consuming an item, or a custom vehicle script detecting stressful behavior.

## Server-Side Admin Or Script Integration [#server-side-admin-or-script-integration]

```lua title="resources/[custom]/server/main.lua"
local src = 12
local stress = math.max(0, math.min(100, 25))

Player(src)?.state:set("stress", stress, true)
```

Use direct state writes when server code already knows the target player ID, such as an admin command or another server-only system. Clamp the value yourself so it stays between `0` and `100`.

`hud:server:GainStress` clamps at `100`. `hud:server:RelieveStress` clamps at `0`. `hud:server:GainStress` also checks `Config.Stress.whitelistedJobs`.
