Hunger, thirst, stress, and custom status management system
The Status system manages player needs like hunger, thirst, and stress. It provides a flexible framework for registering custom statuses with automatic ticking, visual indicators, and gameplay effects.
Hunger status that decreases over time. Low hunger causes health damage.Default Values:
Max: 100
Icon: drumstick-bite
Color: #ca5fe8 (purple)
Flash: true
Effects:
Hunger Level
Effect
Below 25
Start taking damage
Below 10
Take 10 HP damage per tick
0
Take 1 HP damage per tick
Example:
Copy
-- Client side - Check hungerlocal hunger = COMPONENTS.Status.Get:Single('PLAYER_HUNGER')print('Current hunger:', hunger.value)if hunger.value <= 25 then print('Warning: Player is hungry!')end
Stress status that increases from activities. High stress causes screen blur.Default Values:
Max: 100
Icon: brain
Color: #de3333 (red)
Flash: false
Effects:
Stress Level
Effect
40-65 (Level 1)
Light screen blur (600ms intervals)
65-90 (Level 2)
Medium blur (1200ms intervals)
90-100+ (Level 3)
Heavy blur (1800ms intervals)
100+ (Level 4)
Severe blur (2500ms intervals)
Example:
Copy
-- Client side - Check stresslocal stress = COMPONENTS.Status.Get:Single('PLAYER_STRESS')if stress.value >= 75 then print('Player is very stressed')end
-- Client side - Register custom energy statusCOMPONENTS.Status:Register( 'PLAYER_ENERGY', 100, 'bolt', '#fbbf24', true, function(amount, force) -- Tick function - decrease energy over time if not force then amount = -0.5 -- Lose 0.5 energy per tick end local current = COMPONENTS.Status.Get:Single('PLAYER_ENERGY').value local newValue = math.max(0, math.min(100, current + amount)) COMPONENTS.Status.Set:Single('PLAYER_ENERGY', newValue) end, { noReset = false, -- Reset on logout hideZero = false, -- Show when zero hideMax = true -- Hide when full })
-- Client side-- Set hunger to fullCOMPONENTS.Status.Set:Single('PLAYER_HUNGER', 100)-- Set thirst to 50COMPONENTS.Status.Set:Single('PLAYER_THIRST', 50)
-- Server side-- Give player hunger when they eatCOMPONENTS.Status.Modify:Add(source, 'PLAYER_HUNGER', 25)-- Remove stressCOMPONENTS.Status.Modify:Remove(source, 'PLAYER_STRESS', 30)
-- Client sideAddEventHandler('Status:Client:Update', function(name, value) print(string.format('%s changed to %d', name, value)) if name == 'PLAYER_HUNGER' and value <= 10 then -- Player is starving TriggerEvent('mythic-notifications:client:Send', { message = 'You are starving!', type = 'error' }) endend)
-- Server side-- Give hunger to all playersTriggerClientEvent('Status:Client:updateStatus', -1, 'PLAYER_HUNGER', true, 10)-- Remove stress from specific playerTriggerClientEvent('Status:Client:updateStatus', source, 'PLAYER_STRESS', false, 25)
-- Server side - Serve foodRegisterServerEvent('restaurant:server:ServeFood', function(foodItem) local src = source local player = Fetch:Source(src) if not player then return end local char = player:GetData('Character') if not char then return end -- Give food item (auto-modifies hunger when used) COMPONENTS.Inventory:AddItem(char:GetData('SID'), foodItem, 1, {}, 1)end)
-- Client side - Warning systemlocal lastWarning = { hunger = 0, thirst = 0,}CreateThread(function() while true do Wait(30000) -- Check every 30 seconds local hunger = COMPONENTS.Status.Get:Single('PLAYER_HUNGER') local thirst = COMPONENTS.Status.Get:Single('PLAYER_THIRST') if hunger.value <= 25 and os.time() - lastWarning.hunger > 120 then TriggerEvent('mythic-notifications:client:Send', { message = 'You are getting hungry', type = 'warning' }) lastWarning.hunger = os.time() end if thirst.value <= 25 and os.time() - lastWarning.thirst > 120 then TriggerEvent('mythic-notifications:client:Send', { message = 'You are getting thirsty', type = 'warning' }) lastWarning.thirst = os.time() end endend)
Automatic Ticking: Status values automatically decrease over time. The system waits 5 minutes after spawn before starting the tick system to allow players to settle in.
Death Effects: Low hunger/thirst can kill players. Make sure food and water are accessible on your server!