Metabolism System

๐ŸŒŠ CAS Metabolism System - Complete Documentation

๐Ÿ“‹ Table of Contents

  • Overview

  • Features

  • Requirements

  • Installation

  • Configuration

  • API Documentation

  • Theme System

  • Level/XP System

  • Item System

  • Customization

  • Troubleshooting

  • Performance

  • Support


๐ŸŒŸ Overview

CAS Metabolism System is the most advanced metabolism and HUD system for RedM servers, built specifically for the VORP Framework. This system combines modern React/TypeScript technology with comprehensive gameplay mechanics to deliver an unparalleled player experience.

๐ŸŽฏ Key Highlights

  • ๐ŸŽจ 3 Unique Themes: Western, Minimal, and Wave with animated effects

  • โšก Modern React UI with TypeScript for maximum performance

  • ๐ŸŽฎ Complete VORP Integration with character system

  • ๐Ÿ”ง Advanced Customization with drag & drop interface

  • ๐Ÿ“Š Comprehensive Level/XP System with persistent data storage

  • ๐ŸŒ Multi-language Support (EN, FR, ES, DE, TR)

  • ๐ŸŽจ Advanced Color System with presets and individual customization


โœจ Features

๐ŸŽจ Three Stunning Themes

1. Western Theme ๐Ÿค 

  • Traditional hexagonal design with gradient fills

  • Progress text display with percentage values

  • Classic western aesthetic with detailed SVG elements

  • Perfect for traditional roleplay servers

2. Minimal Theme โšช

  • Clean circular progress rings with white stroke indicators

  • Modern minimalist design

  • SVG icon fill system for health/stamina cores

  • Ideal for modern/futuristic servers

3. Wave Theme ๐ŸŒŠ [NEW!]

  • Square containers with animated wave effects

  • Bottom-to-top liquid fill animation

  • Realistic wave physics with CSS animations

  • Dynamic wave colors based on status

  • Gold core enhancement with glowing wave effects

๐Ÿ“Š Comprehensive Metabolism System

Core Statistics

  • Health System: Inner/Outer cores with gold enhancement support

  • Stamina System: Inner/Outer cores with gold enhancement support

  • Hunger: Realistic decay with running multipliers

  • Thirst: Dynamic decrease based on activity

  • Stress System: Visual effects and screen shake

  • Dirt/Cleanliness: Automatic tracking

  • Temperature Display: Real-time weather integration

  • Alcohol Effects: Progressive drunk system with visual distortion

  • Voice Chat Indicator: Real-time microphone status

  • Horse Integration: Health & stamina when mounted

Gold Core Enhancement System โœจ

  • Visual Effects: Glowing icons and wave effects

  • Timer Display: Remaining enhancement time shown above elements

  • Dual Core Support: Inner and outer cores independently enhanced

  • Animation Effects: Pulse and glow animations for enhanced attributes

  • Theme Integration: Works across all three themes

๐ŸŽฏ Level/XP System

Visual Progress

  • Animated XP Bars: Smooth progress animations across all themes

  • Level Display: Current level with XP progress (0-100 per level)

  • Real-time Updates: Instant visual feedback

  • Theme Integration: Unique display for each theme

Data Management

  • JSON Storage: Persistent character data in levelsystem.json

  • Character-based: Individual progress per character identifier

  • Automatic Leveling: XP overflow handling (100 XP per level)

  • Export System: Full API for other resources


๐Ÿ”ง Requirements

Framework Dependencies

  • VORP Core (Latest version) - Required for character system

  • VORP Inventory - Required for item usage system

  • RedM Server (Latest artifacts recommended)

Optional Dependencies

  • CAS Progress Bar - Enhanced progress bar visuals

  • CAS Notification - Custom notification system

  • PMA-Voice or Mumble - Voice chat integration


๐Ÿš€ Installation

Step 1: Download & Extract

# Extract to your resources folder
resources/
โ””โ”€โ”€ cas-metabolism/
    โ”œโ”€โ”€ fxmanifest.lua
    โ”œโ”€โ”€ client/
    โ”œโ”€โ”€ server/
    โ”œโ”€โ”€ config/
    โ””โ”€โ”€ web/

Step 2: Server Configuration

Add to your server.cfg:

# Ensure dependencies start first
ensure vorp_core
ensure vorp_inventory

# Start CAS Metabolism
ensure cas-metabolism

Step 3: Database Setup

No database setup required! The system uses JSON file storage for XP data, which is automatically created and managed.


โš™๏ธ Configuration

๐ŸŽฎ Client Configuration (config/client_config.lua)

Config = {
    -- Commands
    SettingsMenuCommand = "hudsettings",  -- Open HUD settings menu
    HudVisibleCommand = "hudvisible",     -- Toggle HUD visibility
    
    -- Metabolism Decay Settings
    HungerDecreaseTimer = 10,    -- Seconds between hunger decrease
    HungerDecreaseAmount = 0.4,  -- Amount decreased each interval
    ThirstDecreaseTimer = 15,    -- Seconds between thirst decrease
    ThirstDecreaseAmount = 0.4,  -- Amount decreased each interval
    
    -- Running Effects (when player is running)
    Running = {
        HungerDecreaseTimer = 5,   -- Faster hunger decrease
        HungerDecreaseAmount = 0.8,
        ThirstDecreaseTimer = 7,   -- Faster thirst decrease
        ThirstDecreaseAmount = 0.8,
    },
    
    -- System Toggles
    EnableStressSytem = true,              -- Enable stress mechanics
    EnableShakeEffectForStress = true,     -- Screen shake when stressed
    UseCASProgressBar = false,             -- Use custom progress bars
    UseCASNotification = true,             -- Use custom notifications
    DeveloperMode = true,                  -- Debug mode for development
    
    -- Voice Chat Integration
    VoiceChat = "pma-voice", -- Options: "pma-voice" or "mumble"
    
    -- Default Theme for New Players
    DefaultHudTheme = "western", -- Options: "western", "minimal", "wave"
}

๐ŸŽจ HUD Colors Configuration

Config.HudColors = {
    stamina = "#918D2A",        -- Yellow-green
    hunger = "#91552A",         -- Orange-brown
    thirst = "#2A8491",         -- Blue
    stress = "#7E7E7E",         -- Gray
    dirt = "#7E7E7E",           -- Gray
    health = "#B13535",         -- Red
    microphone = "#B135AE",     -- Purple
    weather = "#B135AE",        -- Purple
    drunk = "#35B177",          -- Green
    horsehealth = "#7E7E7E",    -- Gray
    horsestamina = "#B19E35",   -- Gold
    levelprogress = "#DAA520"   -- Gold (Level Progress)
}

๐ŸŒˆ Color Presets System

Config.ColorPresets = {
    default = {
        name = "Default Western",
        description = "Classic western theme colors",
        hudColors = { ... },
        iconColors = { ... },
        emptyIconColors = { ... }
    },
    neon = {
        name = "Neon Nights",
        description = "Bright neon cyberpunk colors",
        hudColors = { ... }
    },
    nature = {
        name = "Nature Green", 
        description = "Earth tones and natural colors",
        hudColors = { ... }
    },
    fire = {
        name = "Fire & Blood",
        description = "Hot reds and burning oranges", 
        hudColors = { ... }
    },
    ice = {
        name = "Ice Cold",
        description = "Cool blues and icy whites",
        hudColors = { ... }
    }
}

๐ŸŽ Item Configuration (config/shared_config.lua)

Config.ItemsToUse = {
    {
        Name = "consumable_coffee",           -- Item spawn name
        Thirst = 300,                        -- Thirst restoration
        Hunger = 100,                        -- Hunger restoration
        Stamina = 200,                       -- Stamina boost
        InnerCoreHealth = 10,                -- Inner health boost
        OuterCoreHealth = 5,                 -- Outer health boost
        InnerCoreHealthGold = 50.0,          -- Inner health gold enhancement
        OuterCoreHealthGold = 50.0,          -- Outer health gold enhancement
        InnerCoreStaminaGold = 50.0,         -- Inner stamina gold enhancement
        OuterCoreStaminaGold = 50.0,         -- Outer stamina gold enhancement
        PropName = "p_mugcoffee01x",         -- 3D prop model
        stress = {
            mode = "decrease",               -- "increase" or "decrease"
            value = 0
        },
        drunk = {
            mode = "increase",               -- Alcohol effect
            value = 0
        },
        Animation = "coffee",                -- Animation type
        Effect = "",                         -- Screen effect
        EffectDuration = "",                 -- Effect duration
        GiveBackItem = "",                   -- Item returned after use
        GiveBackItemAmount = 1,              -- Amount returned
    }
}

๐ŸŒ Localization (config/locale.lua)

Locale = 'en' -- Default language

Locales = {
    ["en"] = {
        ["stamina"] = "Stamina",
        ["hunger"] = "Hunger", 
        ["thirst"] = "Thirst",
        ["stress"] = "Stress",
        ["health"] = "Health",
        ["dirt"] = "Dirt",
        ["microphone"] = "Microphone",
        ["weather"] = "Weather",
        ["drunk"] = "Drunk",
        ["horsehealth"] = "Horse Health",
        ["horsestamina"] = "Horse Stamina",
        ["levelprogress"] = "Level Progress",
        -- Settings menu translations
        ["hudsettings"] = "HUD Settings",
        ["elementvisibility"] = "On/Off Elements",
        ["dragelements"] = "Drag Elements",
        ["close"] = "CLOSE",
        ["save"] = "Save",
        ["cancel"] = "Cancel",
        -- Progress and notification texts
        ["progress_eat"] = "Eating %s",
        ["progress_drink"] = "Drinking %s",
        ["progress_coffee"] = "Drinking coffee: %s",
        ["notify_eat"] = "You ate %s.",
        ["notify_drink"] = "You drank %s.",
    },
    -- Additional languages: fr, tr, es, de
}

๐Ÿ“– CAS-Metabolism Exports Documentation

This document explains all available exports in the CAS-Metabolism system. You can use these exports in your scripts to get, set, or update player metabolism values such as health, stamina, hunger, thirst, stress, etc.


๐Ÿ”น Available Metabolism Keys

Each metabolism type is stored in PlayerMetabolism.Values.

Some keys are simple values (e.g., hunger, thirst), while others are tables with multiple attributes (e.g., health, stamina).

โœ… Simple values

  • hunger โ†’ 0 - 100

  • thirst โ†’ 0 - 100

  • stress โ†’ 0 - 100

  • dirt โ†’ 0 - 100

  • weather โ†’ 0 - 100

  • drunk โ†’ 0 - 100

โœ… Complex values (with gold cores)

These contain inner, outer, and gold core states:

  • stamina

  • microphone

  • horsehealth

  • health

Each of these has:

{
  inner = number (0-100),
  outer = number (0-100),
  innerGold = boolean,
  outerGold = boolean,
  innerGoldTime = number (seconds),
  outerGoldTime = number (seconds)
}

๐Ÿ”น Exports

1. getMetabolismValue(metabolism)

Get the current value of a metabolism key.

local health = exports["cas-metabolism"]:getMetabolismValue("health")
print(json.encode(health))
-- Example output:
-- { inner = 100, outer = 100, innerGold = false, outerGold = false, innerGoldTime = 0, outerGoldTime = 0 }

local hunger = exports["cas-metabolism"]:getMetabolismValue("hunger")
print(hunger) -- 100

2. getAllMetabolismValues()

Get all metabolism values at once.

local allValues = exports["cas-metabolism"]:getAllMetabolismValues()
print(json.encode(allValues))

This returns the full PlayerMetabolism.Values table.


3. setMetabolismValue(metabolism, value)

Set a specific metabolism value. This will update the player status and sync with React.

Example 1 โ€“ Simple value

exports["cas-metabolism"]:setMetabolismValue("hunger", 50)

Example 2 โ€“ Complex value (with gold core)

exports["cas-metabolism"]:setMetabolismValue("health", {
    inner = 80,
    outer = 100,
    innerGold = true,
    outerGold = false,
    innerGoldTime = 60, -- 60 seconds of inner gold core
    outerGoldTime = 0
})

๐Ÿ”น Notes

  • All values are clamped between 0 and 100 automatically.

  • Gold cores (innerGold, outerGold) are boolean values (true/false).

  • Gold core timers (innerGoldTime, outerGoldTime) are integers in seconds.

  • When setting a complex value, you must provide the full table structure.


โœ… Example Use Case

-- Reduce stamina after sprinting
local stamina = exports["cas-metabolism"]:getMetabolismValue("stamina")
stamina.inner = stamina.inner - 10
exports["cas-metabolism"]:setMetabolismValue("stamina", stamina)

-- Make player drunk
exports["cas-metabolism"]:setMetabolismValue("drunk", 80)

With these exports, you can fully control the metabolism system for your players in CAS-Metabolism.


๐ŸŽจ Theme System

Theme Switching

Players can switch between themes in real-time through the HUD settings menu:

Western Theme

  • Design: Hexagonal containers with gradient fills

  • Progress: Text-based percentage display

  • Colors: Traditional western color palette

  • Animation: Smooth fill animations from bottom to top

Minimal Theme

  • Design: Circular progress rings

  • Progress: White stroke progress indicators

  • Colors: Clean, modern color scheme

  • Animation: SVG fill animations for inner cores

Wave Theme ๐ŸŒŠ

  • Design: Square containers with liquid wave effects

  • Progress: Animated wave fill from bottom to top

  • Colors: Dynamic wave colors with gold enhancement

  • Animation: Realistic wave physics with CSS animations

Theme Configuration

-- Set default theme for new players
Config.DefaultHudTheme = "western" -- "western", "minimal", or "wave"

-- Theme settings (automatically configured)
Config.ThemeSettings = {
    western = {
        name = "Classic Western",
        description = "Traditional western style with hexagonal shapes",
        preview = "๐Ÿค "
    },
    minimal = {
        name = "Minimal", 
        description = "Clean circular design with white stroke progress",
        preview = "โšช"
    },
    wave = {
        name = "Wave Effects",
        description = "Animated liquid wave progress with realistic physics",
        preview = "๐ŸŒŠ"
    }
}

๐Ÿ“Š Level/XP System

System Overview

  • XP per Level: 100 XP required for each level

  • Storage: JSON file (levelsystem.json) for persistence

  • Character-based: Individual progress per character identifier

  • Real-time Updates: Instant UI feedback with animations

๐Ÿ“˜ CAS Level System โ€“ Export Usage Guide

This document explains how to use the exports provided by the CAS Level System. These functions allow you to get, add, and remove XP/levels for characters.


๐Ÿ”น Getting Started

First, make sure you correctly retrieve the playerโ€™s character identifier from your core system:

local user = Core.getUser(source) --[[@as User]]
if not user then return end -- is player in session?

local character = user.getUsedCharacter --[[@as Character]]
local identifier = character.charIdentifier -- unique character identifier

You will need identifier for all function calls.


๐Ÿ“ฅ Available Exports

1. getXP(identifier)

Returns the current XP of the given character.

local xp = exports["cas-metabolism"]:getXP(identifier)
print("Current XP:", xp)

2. addXP(amount, identifier, source)

Adds XP to a character. If XP reaches 100, it automatically levels up.

local xpToAdd = 50
exports["cas-metabolism"]:addXP(xpToAdd, identifier, source)

๐Ÿ’ก Example: Reward player XP after finishing a mission.


3. removeXP(amount, identifier, source)

Removes XP from a character. If XP goes below 0, the character levels down.

local xpToRemove = 30
exports["cas-metabolism"]:removeXP(xpToRemove, identifier, source)

4. getLevel(identifier)

Returns the current level of the given character.

local level = exports["cas-metabolism"]:getLevel(identifier)
print("Current Level:", level)

5. getPlayerLevelData(identifier)

Returns a table with both XP and level values.

local data = exports["cas-metabolism"]:getPlayerLevelData(identifier)
if data then
    print(("Level: %s | XP: %s"):format(data.level, data.xp))
end

๐Ÿ“Œ Example Use Case

Reward a player with XP when completing a job:

local user = Core.getUser(source) --[[@as User]]
if not user then return end

local character = user.getUsedCharacter --[[@as Character]]
local identifier = character.charIdentifier

-- Add 25 XP to the player
exports["cas-levelsystem"]:addXP(25, identifier, source)

-- Print new level and XP
local data = exports["cas-metabolism"]:getPlayerLevelData(identifier)
if data then
    print(("Player %s is now Level %d with %d XP"):format(identifier, data.level, data.xp))
end

โœจ Thatโ€™s it! With these exports you can easily integrate XP and leveling into your scripts.

๐ŸŽ Item System

40+ Pre-configured Items

Alcoholic Beverages

  • whisky: High alcohol content with drunk effects

  • wine: Moderate alcohol with thirst restoration

  • beer: Light alcohol with stamina boost

  • vodka: Strong alcohol with health boost

  • tequila: Premium alcohol with enhanced effects

  • tropicalPunchMoonshine: Moonshine variant

  • wildCiderMoonshine: Cider moonshine variant

  • raspberryale: Fruit-flavored alcoholic beverage

Food Categories

  • Breakfast Items: consumable_breakfast

  • Fruits: consumable_peach, consumable_pear

  • Vegetables: consumable_veggies

  • Fish: consumable_bluegil, consumable_salmon, consumable_trout

  • Desserts: consumable_chocolate, cheesecake, consumable_blueberrypie

  • Baked Goods: Various cakes and pastries

Medical Supplies

  • bandage_2: Outer health restoration with bandage animation

  • syringe_2: Inner health restoration with injection animation

Beverages

  • consumable_coffee: Stamina boost with gold core enhancement

  • milk: Nutritious drink with health benefits

  • consumable_raspberrywater: Fruit-flavored water

Advanced Item Configuration

Gold Core Enhancement Items

{
    Name = "consumable_coffee",
    Thirst = 300,
    Hunger = 100,
    Stamina = 200,
    InnerCoreHealth = 10,
    OuterCoreHealth = 5,
    -- Gold Core Enhancements (duration in seconds)
    InnerCoreHealthGold = 50.0,    -- 50 seconds of inner health gold
    OuterCoreHealthGold = 50.0,    -- 50 seconds of outer health gold
    InnerCoreStaminaGold = 50.0,   -- 50 seconds of inner stamina gold
    OuterCoreStaminaGold = 50.0,   -- 50 seconds of outer stamina gold
    PropName = "p_mugcoffee01x",
    Animation = "coffee",
}

Animation System

Available animation types:

  • "eat": General eating animation with props

  • "drink": Drinking animation with bottles

  • "coffee": Special coffee drinking animation

  • "stew": Eating stew with spoon animation

  • "syringe": Medical injection animation

  • "bandage": Bandage application animation

Screen Effects

-- Available screen effects
Effect = "PlayerDrunkSaloon1",  -- Drunk vision effect
EffectDuration = 1,             -- Duration in minutes

Item Usage Flow

  1. Player uses item โ†’ VORP Inventory triggers usage

  2. Animation plays โ†’ 6-second animation with prop

  3. Effects applied โ†’ Metabolism values updated

  4. Screen effects โ†’ Visual effects if configured

  5. Notification โ†’ Success message displayed

  6. Return item โ†’ Optional item returned (e.g., empty bottle)


๐ŸŽจ Customization

Drag & Drop Interface

  • Activation: Use /hudsettings โ†’ "Drag Elements"

  • Visual Feedback: DnD indicators appear on all elements

  • Persistent Positions: All positions saved automatically

  • Reset Function: One-click position reset to defaults

Individual Element Sizing

  • Scale Range: 0.5x to 2.0x for each element

  • Independent Scaling: Each element sized individually

  • Real-time Preview: See changes instantly

  • Persistent Settings: Saved across sessions

Advanced Color System

Three Color Types per Element

  1. Background/Stroke Color: Main element color (theme-dependent)

  2. Icon Color: Full state icon color

  3. Empty Icon Color: Empty state icon color

Color Presets

  • 5 Pre-made Presets: Default, Neon, Nature, Fire, Ice

  • One-click Application: Apply entire color scheme instantly

  • Theme Compatibility: Works across all themes

Individual Customization

  • Per-element Colors: Customize each element individually

  • Bulk Operations: Apply colors to all elements at once

  • Real-time Preview: See changes immediately

  • Persistent Storage: Colors saved in localStorage

Theme-specific Color Behavior

Western Theme

  • Background Color: Hexagon fill gradient

  • Icon Color: SVG icon fill color

  • Empty Icon Color: Icon color when empty

Minimal Theme

  • Stroke Color: Circular progress ring color

  • Icon Color: Full SVG icon fill

  • Empty Icon Color: Empty SVG icon fill

Wave Theme ๐ŸŒŠ

  • Wave Color: Liquid wave fill color

  • Icon Color: Center icon color

  • Empty Icon Color: Container background color


๐Ÿ”ง Advanced Features

Gold Core Enhancement System โœจ

Visual Effects

  • Glowing Icons: Enhanced icons with gold color and glow effect

  • Wave Enhancement: Gold-colored waves in Wave theme

  • Pulse Animation: Breathing glow effect for enhanced attributes

  • Timer Display: Remaining enhancement time above elements

Implementation

-- Apply gold core enhancement
Citizen.InvokeNative(0x4AF5A4C7B9157D14, PlayerPedId(), 0, 50.0) -- Inner Health Gold
Citizen.InvokeNative(0xF6A7C08DF2E28B28, PlayerPedId(), 0, 50.0, true) -- Outer Health Gold
Citizen.InvokeNative(0x4AF5A4C7B9157D14, PlayerPedId(), 1, 50.0) -- Inner Stamina Gold
Citizen.InvokeNative(0xF6A7C08DF2E28B28, PlayerPedId(), 1, 50.0, true) -- Outer Stamina Gold

Stress System

  • Progressive Effects: Different intensities based on stress level

  • Screen Shake: Configurable shake effects at high stress

  • Shooting Integration: Stress increases when shooting

  • Visual Feedback: Real-time stress indication in HUD

Alcohol System

  • Progressive Intoxication: Multiple drunk levels

  • Screen Effects: Visual distortion when drunk

  • Ragdoll Effects: Character stumbles when heavily intoxicated

  • Realistic Recovery: Time-based alcohol decrease

Horse Integration

  • Automatic Detection: Shows horse stats when mounted

  • Health & Stamina: Both inner and outer cores

  • Dynamic Display: Appears/disappears based on mount status

  • Gold Core Support: Enhanced horse attributes

Voice Chat Integration

  • Real-time Indicator: Shows when player is talking

  • Multiple Systems: Supports PMA-Voice and Mumble

  • Visual Feedback: Microphone element fills when active


๐ŸŽฎ User Experience

In-Game Commands

/hudsettings    # Open HUD customization menu
/hudvisible     # Toggle HUD visibility
/addxp [amount] # Add XP (admin only)
/removexp [amount] # Remove XP (admin only)

Settings Menu Features

1. Element Visibility

  • Show/hide any HUD element

  • Individual toggle switches

  • Real-time preview

  • Persistent settings

2. Drag Elements

  • Move elements anywhere on screen

  • Visual drag indicators

  • Snap-to-grid feel

  • Position memory

3. HUD Themes

  • Switch between Western/Minimal/Wave

  • Instant theme changes

  • Position preservation

  • Theme-specific optimizations

4. Individual Sizes

  • Scale each element 0.5x-2.0x

  • Real-time size preview

  • Independent scaling

  • Size memory

5. Color Presets

  • Apply pre-made color schemes

  • 5 beautiful presets included

  • One-click application

  • Theme compatibility

6. Color Customization

  • Individual element color control

  • 3 colors per element

  • Bulk color operations

  • Real-time preview


๐Ÿ”ง Technical Implementation

React/TypeScript Architecture

// State Management with Redux Toolkit
interface RootState {
  data: MetabolismData;      // Metabolism values
  ui: UIState;               // Theme, sizes, settings
  config: ConfigState;       // Colors and configuration
  locale: LocaleState;       // Language data
  dnd: DragDropState;        // Drag & drop state
}

// Component Structure
App.tsx                     // Main application container
โ”œโ”€โ”€ Head.tsx               // Header elements (money, gold, timer, ID)
โ”œโ”€โ”€ Metabolism.tsx         // Western theme metabolism
โ”œโ”€โ”€ Metabolism-Minimal.tsx // Minimal theme metabolism  
โ”œโ”€โ”€ Metabolism-Wave.tsx    // Wave theme metabolism
โ””โ”€โ”€ Settings.tsx           // Settings menu system

Performance Optimizations

  • Efficient Rendering: Only updates changed elements

  • Memory Management: Proper cleanup of resources

  • Network Optimization: Minimal network traffic

  • Animation Performance: 60fps smooth animations

Data Persistence

-- XP Data Storage (levelsystem.json)
{
    "char_123": {
        "level": 5,
        "xp": 75
    },
    "char_456": {
        "level": 3,
        "xp": 42
    }
}

-- Client-side Storage (localStorage)
- hud_theme: "western" | "minimal" | "wave"
- element_sizes: { stamina: 1.2, health: 0.8, ... }
- custom_hud_colors: { stamina: "#918D2A", ... }
- [element]_position: { x: 100, y: 50 }

๐ŸŽฏ Integration Examples

Basic Integration

-- Check player level for unlocks
local user = VorpCore.getUser(source)
local character = user.getUsedCharacter
local level = exports['cas-metabolism']:getLevel(character.charIdentifier)

if level >= 10 then
    -- Unlock special features
    TriggerClientEvent('your-script:unlockFeature', source, 'advanced_crafting')
end

Metabolism Monitoring

-- Monitor player health for medical system
local health = exports['cas-metabolism']:getMetabolismValue('health')
if health.inner < 20 then
    TriggerClientEvent('medical-system:lowHealth', source)
end

XP Rewards System

-- Reward XP for various activities
RegisterNetEvent("your-script:activityComplete")
AddEventHandler("your-script:activityComplete", function(activityType)
    local user = VorpCore.getUser(source)
    local character = user.getUsedCharacter
    local identifier = character.charIdentifier
    
    local xpRewards = {
        fishing = 10,
        hunting = 15,
        crafting = 5,
        mission = 25
    }
    
    local xpAmount = xpRewards[activityType] or 5
    addXP(xpAmount, identifier, source)
end)

๐Ÿ”ง Advanced Configuration

Metabolism Decay Rates

-- Base decay rates (idle/walking)
Config.HungerDecreaseTimer = 10    -- Every 10 seconds
Config.HungerDecreaseAmount = 0.4  -- Decrease by 0.4

-- Running multipliers (faster decay when running)
Config.Running = {
    HungerDecreaseTimer = 5,       -- Every 5 seconds
    HungerDecreaseAmount = 0.8,    -- Decrease by 0.8
    ThirstDecreaseTimer = 7,       -- Every 7 seconds  
    ThirstDecreaseAmount = 0.8,    -- Decrease by 0.8
}

Stress System Configuration

-- Enable/disable stress system
Config.EnableStressSytem = true

-- Enable screen shake effects
Config.EnableShakeEffectForStress = true

-- Stress increases when shooting (automatic)
-- Stress decreases over time (automatic)

Voice Chat Configuration

-- Voice chat system integration
Config.VoiceChat = "pma-voice" -- or "mumble"

-- Microphone indicator automatically shows when talking
-- Works with both PMA-Voice and Mumble systems

๐ŸŽจ Customization Guide

For Server Owners

Setting Default Colors

-- Customize default colors in client_config.lua
Config.HudColors = {
    stamina = "#YOUR_COLOR",
    hunger = "#YOUR_COLOR",
    -- ... other elements
}

Adding Custom Items

-- Add to Config.ItemsToUse in shared_config.lua
{
    Name = "your_custom_item",
    Thirst = 200,
    Hunger = 300,
    Animation = "eat",
    PropName = "your_prop_model",
    stress = { mode = "decrease", value = 10 },
    -- ... other properties
}

For Players

Theme Customization

  1. Use /hudsettings to open settings

  2. Select "HUD Themes" to switch themes

  3. Use "Color Presets" for quick color schemes

  4. Use "Color Customization" for individual control

Layout Customization

  1. Use "Drag Elements" to move elements

  2. Use "Individual Sizes" to scale elements

  3. Use "Element Visibility" to show/hide elements

  4. All changes are saved automatically


๐Ÿ› Troubleshooting

Common Issues

HUD Not Showing

-- Check if character is loaded
if not PlayerLoaded then
    -- Wait for character selection
    return
end

-- Manually trigger HUD display
TriggerEvent('vorp:SelectedCharacter', charId)

XP Not Updating

  1. Check server console for errors

  2. Verify character identifier exists

  3. Check levelsystem.json file permissions

  4. Ensure VORP Core is running properly

Items Not Working

  1. Verify VORP Inventory is running

  2. Check item names match exactly in database

  3. Ensure items exist in VORP items table

  4. Check console for item registration errors

Colors Not Applying

  1. Clear browser cache (F5 in NUI)

  2. Check localStorage for saved settings

  3. Reset to defaults in HUD settings

  4. Verify color format is valid hex

Positions Not Saving

  1. Check browser localStorage permissions

  2. Verify position keys are correct

  3. Reset positions if corrupted

  4. Check console for position errors

Debug Mode

Enable debug mode for detailed logging:

Config.DeveloperMode = true

This enables:

  • Detailed console logging

  • Automatic HUD display for testing

  • Development XP data loading

  • Enhanced error messages

Console Commands for Testing

# Test commands (admin only)
addxp 50              # Add 50 XP
removexp 25           # Remove 25 XP
addconsumablesitem    # Add all consumable items

๐Ÿ“ˆ Performance

Resource Usage

  • Client Memory: ~15-25MB

  • Server Memory: ~5-10MB

  • Network Usage: <1KB/s per player

  • CPU Usage: <1% on modern hardware

  • Update Frequency: 250ms for smooth animations

Optimization Features

  • Efficient React Rendering: Minimal re-renders with proper state management

  • Optimized Network Traffic: Only sends changed data

  • Memory Leak Prevention: Proper cleanup of event listeners

  • Smooth Animations: 60fps performance with Framer Motion

  • Lazy Loading: Components loaded only when needed

Scalability

  • High Player Count: Tested with 200+ concurrent players

  • Low Latency: Minimal network overhead

  • Stable Performance: No memory leaks or performance degradation

  • Cross-platform: Works on all RedM supported platforms


๐Ÿ”’ Security & Validation

Server-side Validation

  • Metabolism Changes: All changes validated server-side

  • XP System: Anti-cheat protection for level manipulation

  • Item Usage: Secure item validation through VORP Inventory

  • Configuration Protection: Server-side config validation

Data Integrity

  • Character-based Storage: Secure per-character data

  • JSON Validation: Proper data format validation

  • Backup System: Automatic data backup on changes

  • Error Recovery: Graceful handling of corrupted data


๐ŸŒ Multi-language Support

Supported Languages

  • English (en) - Default

  • French (fr) - Franรงais

  • Spanish (es) - Espaรฑol

  • German (de) - Deutsch

  • Turkish (tr) - Tรผrkรงe

Adding New Languages

-- Add to config/locale.lua
Locales["your_lang"] = {
    ["stamina"] = "Your Translation",
    ["hunger"] = "Your Translation",
    -- ... other translations
}

-- Set default language
Locale = 'your_lang'

Dynamic Language Loading

  • Language changes without server restart

  • Automatic UI updates

  • Fallback to English for missing translations

  • Client-side language switching


๐Ÿš€ Future Updates

Planned Features

  • Additional Themes: More visual themes

  • Enhanced Animations: More animation types

  • Extended API: More integration options

  • Performance Improvements: Continued optimization

Community Requests

  • Custom Themes: User-created theme support

  • More Languages: Additional language support

  • Enhanced Effects: More visual effects

  • Mobile Optimization: Touch-friendly interface


๐Ÿ“ž Support

Getting Help

  1. Read Documentation: Check this guide thoroughly

  2. Check Console: Look for error messages

  3. Debug Mode: Enable for detailed logging

  4. Community: Ask in our Discord server

Reporting Issues

Include in your report:

  • Server Version: RedM build number

  • VORP Version: Core and inventory versions

  • Error Messages: Full console output

  • Steps to Reproduce: Detailed reproduction steps

  • Configuration: Your config files

Feature Requests

We welcome suggestions! Include:

  • Detailed Description: What you want to achieve

  • Use Case: Why this feature would be useful

  • Implementation Ideas: How you think it should work


๐Ÿ“„ License & Credits

License

This resource is protected and licensed. Please respect the license terms and do not redistribute without permission.

Credits

  • Development: Code After S*x Team

  • Framework: VORP Core Integration

  • UI Framework: React + TypeScript

  • Animations: Framer Motion

  • State Management: Redux Toolkit


๐Ÿ“Š Version Information

Current Version: v2.0.0

  • โœ… Complete metabolism system

  • โœ… 3 unique themes (Western, Minimal, Wave)

  • โœ… Advanced customization system

  • โœ… Level/XP system with JSON storage

  • โœ… 40+ pre-configured items

  • โœ… Gold core enhancement system

  • โœ… Multi-language support

  • โœ… VORP Framework integration


This documentation covers the complete CAS Metabolism System for RedM servers using the VORP Framework. For additional support or custom development, contact the Code After Sx team.*

๐ŸŒŠ Experience the future of RedM metabolism systems with CAS Metabolism!

Last updated