Exports & API

Exports & API

legends_stress provides server-side and client-side exports for stress management, stress relief effects, and yoga mat integration.

Server Exports

Stress Relief Item Exports

useStressPill

Triggers the stress pill effect for a player. Designed for use with inventory systems like ox_inventory.

exports['legends_stress']:useStressPill(source)

Parameters:

  • source (number): The player's server ID

ox_inventory Integration:

['stress_pill'] = {
    label = 'Stress Pills',
    server = {
        export = 'legends_stress.useStressPill'
    }
}

useJoint

Triggers the joint smoking effect for a player. Designed for use with inventory systems.

exports['legends_stress']:useJoint(source)

Parameters:

  • source (number): The player's server ID

ox_inventory Integration:

['joint'] = {
    label = 'Joint',
    server = {
        export = 'legends_stress.useJoint'
    }
}

Yoga Mat Exports

useMatBlue

Triggers placement of a blue yoga mat. For ox_inventory server export integration.

exports['legends_stress']:useMatBlue(source)

ox_inventory Integration:

['mat_blue'] = {
    label = 'Blue Yoga Mat',
    weight = 500,
    stack = false,
    close = true,
    description = 'A comfortable blue yoga mat for stress relief sessions.',
    server = {
        export = 'legends_stress.useMatBlue'
    }
}

useMatGray

Triggers placement of a gray yoga mat.

exports['legends_stress']:useMatGray(source)

ox_inventory Integration:

['mat_gray'] = {
    label = 'Gray Yoga Mat',
    weight = 500,
    stack = false,
    close = true,
    description = 'A sleek gray yoga mat for stress relief sessions.',
    server = {
        export = 'legends_stress.useMatGray'
    }
}

useMatRed

Triggers placement of a red yoga mat.

exports['legends_stress']:useMatRed(source)

ox_inventory Integration:

['mat_red'] = {
    label = 'Red Yoga Mat',
    weight = 500,
    stack = false,
    close = true,
    description = 'A vibrant red yoga mat for stress relief sessions.',
    server = {
        export = 'legends_stress.useMatRed'
    }
}

useMatPro

Triggers placement of a professional yoga mat.

exports['legends_stress']:useMatPro(source)

ox_inventory Integration:

['mat_pro'] = {
    label = 'Pro Yoga Mat',
    weight = 500,
    stack = false,
    close = true,
    description = 'A professional-grade yoga mat for the ultimate stress relief.',
    server = {
        export = 'legends_stress.useMatPro'
    }
}

GetActiveMats

Returns a table of all currently active yoga mats on the server.

local mats = exports['legends_stress']:GetActiveMats()

Returns: table - A table of active mats indexed by their network ID

Return Structure:

{
    ["yoga_mat_1_1234567890"] = {
        coords = vector3(x, y, z),
        heading = 180.0,
        prop = "prop_yoga_mat_01",
        itemName = "mat_blue",
        ownerId = 1,           -- Player server ID
        inUse = false,         -- Whether someone is doing yoga
        currentUser = nil,     -- Server ID of user (if in use)
        despawnTime = 1234567890
    },
    -- ... more mats
}

Example Usage:

-- Count active yoga mats
local mats = exports['legends_stress']:GetActiveMats()
local count = 0
for _ in pairs(mats) do count = count + 1 end
print('Active yoga mats: ' .. count)

Client Exports

useStresspill

Triggers the stress pill effect on the local player.

exports['legends_stress']:useStresspill()

Effects:

  • Plays pill-taking animation
  • Shows progress bar
  • Applies visual screen effect
  • Gradually reduces stress over the configured duration

useJoint

Triggers the joint smoking effect on the local player.

exports['legends_stress']:useJoint()

Effects:

  • Plays smoking animation
  • Shows progress bar
  • Applies visual screen effect
  • Gradually reduces stress over the configured duration

GetCachedStress

Returns the player's current cached stress level without making a server request.

local stress = exports['legends_stress']:GetCachedStress()

Returns: number - The player's current stress level (0-100)

Example Usage:

-- Check stress before an action
local stress = exports['legends_stress']:GetCachedStress()
if stress > 80 then
    print('You are too stressed to do this!')
end

This returns the locally cached stress value which may be slightly behind the server value. Use this for performance-sensitive checks.


PlaceYogaMat

Triggers the yoga mat placement sequence for the local player.

exports['legends_stress']:PlaceYogaMat(propName)

Parameters:

  • propName (string): The prop model name to spawn (e.g., "prop_yoga_mat_01")

Example Usage:

-- Place a blue yoga mat
exports['legends_stress']:PlaceYogaMat('prop_yoga_mat_01')
 
-- Place a professional mat
exports['legends_stress']:PlaceYogaMat('p_yoga_mat_01_s')

Prop Model Reference:

Mat TypeProp Model
Blueprop_yoga_mat_01
Grayprop_yoga_mat_02
Redprop_yoga_mat_03
Prop_yoga_mat_01_s

Integration Examples

Custom Command

-- Client-side: Custom stress relief command
RegisterCommand('takepill', function()
    exports['legends_stress']:useStresspill()
end)
 
RegisterCommand('smokejoint', function()
    exports['legends_stress']:useJoint()
end)
 
RegisterCommand('checkstress', function()
    local stress = exports['legends_stress']:GetCachedStress()
    print('Current stress: ' .. stress .. '%')
end)

qb-inventory / qbx_core Useable Items

-- Server-side: Register useable items for QB-Core
 
-- Stress Relief Items
QBCore.Functions.CreateUseableItem('stress_pill', function(source)
    exports['legends_stress']:useStressPill(source)
end)
 
QBCore.Functions.CreateUseableItem('joint', function(source)
    exports['legends_stress']:useJoint(source)
end)
 
-- Yoga Mat Items
QBCore.Functions.CreateUseableItem('mat_blue', function(source)
    exports['legends_stress']:useMatBlue(source)
end)
 
QBCore.Functions.CreateUseableItem('mat_gray', function(source)
    exports['legends_stress']:useMatGray(source)
end)
 
QBCore.Functions.CreateUseableItem('mat_red', function(source)
    exports['legends_stress']:useMatRed(source)
end)
 
QBCore.Functions.CreateUseableItem('mat_pro', function(source)
    exports['legends_stress']:useMatPro(source)
end)

ESX Useable Items

-- Server-side: Register useable items for ESX
 
-- Stress Relief Items
ESX.RegisterUsableItem('stress_pill', function(source)
    exports['legends_stress']:useStressPill(source)
end)
 
ESX.RegisterUsableItem('joint', function(source)
    exports['legends_stress']:useJoint(source)
end)
 
-- Yoga Mat Items
ESX.RegisterUsableItem('mat_blue', function(source)
    exports['legends_stress']:useMatBlue(source)
end)
 
ESX.RegisterUsableItem('mat_gray', function(source)
    exports['legends_stress']:useMatGray(source)
end)
 
ESX.RegisterUsableItem('mat_red', function(source)
    exports['legends_stress']:useMatRed(source)
end)
 
ESX.RegisterUsableItem('mat_pro', function(source)
    exports['legends_stress']:useMatPro(source)
end)

Custom Stress Relief Item

-- Server-side: Create your own stress relief item
RegisterNetEvent('myresource:useCalmingTea', function()
    local src = source
 
    -- Check if player has item
    local count = exports.ox_inventory:Search(src, 'count', 'calming_tea')
    if count < 1 then return end
 
    -- Remove item
    exports.ox_inventory:RemoveItem(src, 'calming_tea', 1)
 
    -- Trigger stress relief (uses stress pill effect)
    exports['legends_stress']:useStressPill(src)
end)

Stress-Based Mechanics

-- Client-side: Implement stress-based gameplay mechanics
 
-- Disable certain actions at high stress
CreateThread(function()
    while true do
        Wait(1000)
        local stress = exports['legends_stress']:GetCachedStress()
 
        if stress >= 90 then
            -- Disable aiming accuracy at very high stress
            SetPlayerWeaponAccuracy(PlayerId(), 0.5)
        elseif stress >= 70 then
            -- Reduce accuracy at high stress
            SetPlayerWeaponAccuracy(PlayerId(), 0.75)
        else
            -- Normal accuracy
            SetPlayerWeaponAccuracy(PlayerId(), 1.0)
        end
    end
end)

Yoga Mat Admin Command

-- Server-side: Admin command to list active yoga mats
RegisterCommand('listmats', function(source, args, rawCommand)
    local mats = exports['legends_stress']:GetActiveMats()
 
    local count = 0
    for netId, matData in pairs(mats) do
        count = count + 1
        print(('Mat %s: Owner=%d, InUse=%s, Coords=%.2f, %.2f, %.2f'):format(
            netId,
            matData.ownerId,
            tostring(matData.inUse),
            matData.coords.x,
            matData.coords.y,
            matData.coords.z
        ))
    end
 
    print(('Total active yoga mats: %d'):format(count))
end, true) -- true = restricted to admin

Customization

Editable Files

The following files can be customized without affecting core functionality:

  • client/editable/ - Client-side customization options
  • server/editable/ - Server-side customization options
  • config/config.lua - All configuration settings

Stress Relief Configuration

Configure stress relief items in config/config.lua:

Config.DecreaseStress = {
    ["stress_pill"] = {
        value = 20,              -- Total stress reduction
        progressbarduration = 5, -- Progress bar time (seconds)
        effectDuration = 35      -- Effect duration (seconds)
    },
    ["joint"] = {
        value = 25,
        progressbarduration = 5,
        effectDuration = 35
    }
}

Yoga Mat Configuration

Configure yoga mats in config/config.lua:

Config.YogaMat = {
    enabled = true,
    stressRelief = 50,       -- Stress reduced per session
    yogaDuration = 30,       -- Animation duration (seconds)
    cooldown = 60,           -- Cooldown between sessions (seconds)
    items = {
        ["mat_blue"] = "prop_yoga_mat_01",
        ["mat_gray"] = "prop_yoga_mat_02",
        ["mat_red"]  = "prop_yoga_mat_03",
        ["mat_pro"]  = "p_yoga_mat_01_s",
    }
}

Framework Compatibility

The resource automatically detects and works with:

FrameworkStress Storage
QB-CorePlayer metadata
QBX-CorePlayer metadata
ESXplayer_stress database table (auto-created)

Need Help?

Join our Discord for support: discord.gg/lgnds (opens in a new tab)


Legends Store - Premium FiveM Scripts