Gridbase
Paid releasesDime Skills

Type Definitions

Lua type references and data structures for Dime Skills

Type Definitions

Type references for all data structures used in Dime Skills. While Lua is dynamically typed, these definitions help you understand expected data formats.

Skill Data Types

SkillData

Player's current skill progression data.

{
    level: number,        -- Current level (1 to lvlMax)
    xp: number,           -- Current XP toward next level
    statlevel: number,    -- Internal stat level for built-in skills
    lastupdated: number   -- Unix timestamp of last update
}

Example:

{
    level = 15,
    xp = 487.3,
    statlevel = 50.0,
    lastupdated = 1699564800
}

Usage:

local skill = exports.dime_skills:grabSkill(source, 'crafting')
print(skill.level)  -- 15
print(skill.xp)     -- 487.3

SkillConfig

Configuration for a skill.

{
    visuals: SkillVisuals,
    levels: SkillLevels,
    rewardMax: number,
    reduceMax: number,
    action?: SkillAction,
    bonusmultiplier?: number,
    job?: string
}

Example:

{
    visuals = {
        category = 'Crafting',
        label = 'Engineering',
        description = 'Create complex mechanisms...',
        icon = 'tools'
    },
    levels = {
        lvlMulti = { default = 3.0 },
        lvlMax = 30
    },
    rewardMax = 20,
    reduceMax = 20,
    job = 'mechanic'
}

SkillVisuals

Visual properties for UI display.

{
    category: string,      -- UI category grouping
    label: string,         -- Display name
    description: string,   -- Detailed description
    icon?: string,         -- FontAwesome icon name
    iconColor?: string     -- Hex color code
}

Example:

{
    category = 'Character',
    label = 'Bodybuilding',
    description = 'Build your muscular strength...',
    icon = 'dumbbell',
    iconColor = '#EF4444'
}

Icon Examples:

  • 'tools' - Wrench icon
  • 'car-side' - Car icon
  • 'running' - Running person
  • 'fish' - Fish icon

SkillLevels

Level progression configuration.

{
    lvlMulti: table<number, number> | { default: number },
    lvlMax: number,
    degrade?: SkillDegrade
}

Example:

{
    lvlMulti = {
        default = 2.5,
        [1] = 1.5,
        [2] = 2.0,
        [3] = 2.5
    },
    lvlMax = 30,
    degrade = {
        enabled = true,
        time = 168,
        amount = 100
    }
}

Level Multipliers:

  • default: Used for any level not specifically defined
  • [level]: Specific multiplier for that level

SkillDegrade

XP degradation configuration.

{
    enabled: boolean,   -- Enable degradation
    time: number,       -- Hours between degradation
    amount: number      -- XP to remove
}

Example:

{
    enabled = true,
    time = 168,    -- 1 week
    amount = 50
}

SkillAction

Action configuration for automatic progression.

{
    builtIn?: boolean,  -- Uses built-in progression
    cooldown?: number,  -- Seconds between XP gains
    xp?: number,        -- XP per cooldown
    event?: string      -- Event triggered on level up
}

Example:

{
    builtIn = true,
    cooldown = 30,
    xp = 10,
    event = 'myresource:levelUp'
}

Notification Types

SkillNotifyData

Data for skill notifications.

{
    skillName: string,              -- Skill display name
    oldLevel: number,                -- Previous level
    newLevel: number,                -- New level
    oldPoints: number,               -- Previous XP
    newPoints: number,               -- New XP
    oldProgress: number,             -- Previous progress (%)
    newProgress: number,             -- New progress (%)
    requiredXPForOldLevel?: number, -- XP for old level
    requiredXPForNewLevel?: number, -- XP for new level
    bonusMultiplier?: number,       -- Applied multiplier
    icon?: string,                   -- FontAwesome icon
    iconColor?: string,              -- Hex color
    change: boolean                  -- true = gain, false = loss
}

Example:

{
    skillName = 'Engineering',
    oldLevel = 5,
    newLevel = 6,
    oldPoints = 450.0,
    newPoints = 50.0,
    oldProgress = 75.0,
    newProgress = 8.3,
    requiredXPForOldLevel = 600,
    requiredXPForNewLevel = 700,
    bonusMultiplier = 1.0,
    icon = 'tools',
    iconColor = '#3B82F6',
    change = true
}

Crafting Types

CraftingSkills

Skill requirements and rewards for crafting.

{
    required?: table<string, number>,  -- Required skill levels
    reward?: table<string, number>      -- XP rewards
}

Example:

{
    required = {
        crafting = 10,
        chemistry = 5
    },
    reward = {
        crafting = 15,
        chemistry = 10
    }
}

Usage in ox_inventory:

['weapon_pistol'] = {
    label = 'Pistol',
    -- ... other properties
    skills = {
        required = {
            weaponary = 15
        },
        reward = {
            weaponary = 25
        }
    }
}

Registration Types

AddSkillData

Data for registering a new skill.

{
    name: string,
    label: string,
    description: string,
    category: string,
    icon?: string,
    iconColor?: string,
    levels: {
        lvlMulti: table<number, number> | { default: number },
        lvlMax: number,
        degrade?: SkillDegrade
    },
    action?: SkillAction,
    rewardMax: number,
    reduceMax: number,
    bonusmultiplier?: number,
    job?: string
}

Example:

{
    name = 'hacking',
    label = 'Hacking',
    description = 'Bypass security systems...',
    category = 'Illegal',
    icon = 'laptop-code',
    iconColor = '#10B981',
    levels = {
        lvlMulti = { default = 3.0 },
        lvlMax = 40
    },
    rewardMax = 30,
    reduceMax = 15,
    action = {
        event = 'hacking:levelUp'
    }
}

Config Types

Config

Main configuration object.

{
    Framework: 'QBOX' | 'ESX' | 'OX' | 'QBCORE' | 'Custom',
    skillNotify: 'UI' | 'ox_lib',
    keybind: string | false,
    command: string,
    toggleNotifyCommand: string,
    disableSafetyCheck: boolean,
    Debug: boolean,
    deductOnline: boolean,
    Strength?: StrengthConfig,
    Driving?: DrivingConfig,
    Stamina?: StaminaConfig,
    craftingSkills: boolean,
    Diving: boolean,
    DivingToStamina?: DivingToStaminaConfig,
    skills: table<string, SkillConfig>
}

StrengthConfig

Configuration for strength system.

{
    enabled: boolean,
    baseModifier: number,
    levelMultiplier: number,
    minModifier: number,
    maxModifier: number
}

Example:

{
    enabled = true,
    baseModifier = -0.35,
    levelMultiplier = 1.00,
    minModifier = 0.05,
    maxModifier = 2.0
}

DrivingConfig

Configuration for driving system.

{
    enabled: boolean,
    SpeedUnit: 'MPH' | 'KMH',
    SpeedThreshold: number,
    validVehicleClasses: table<number, boolean>
}

Example:

{
    enabled = true,
    SpeedUnit = 'MPH',
    SpeedThreshold = 100,
    validVehicleClasses = {
        [0] = true,   -- Compacts
        [8] = true,   -- Motorcycles
        [13] = false  -- Bicycles
    }
}

StaminaConfig

Configuration for stamina system.

{
    enabled: boolean,
    xpGainMethod: 'cooldown' | 'continuous',
    action: {
        builtIn: boolean,
        cooldown: number,
        xp: number
    }
}

Example:

{
    enabled = true,
    xpGainMethod = "cooldown",
    action = {
        builtIn = true,
        cooldown = 30,
        xp = 10
    }
}

DivingToStaminaConfig

Configuration for diving to stamina conversion.

{
    enabled: boolean,
    stepsToSkip: number
}

Example:

{
    enabled = true,
    stepsToSkip = 2
}

Callback Types

GetSkillsByIdentifierCallback

Callback function for getSkillsByIdentifier export.

function(data: SkillInfo[])

SkillInfo Structure:

{
    name: string,
    visuals: { label: string },
    level: number,
    xp: number,
    percent: number
}

Example:

exports.dime_skills:getSkillsByIdentifier('ABC12345', function(skills)
    for _, skill in ipairs(skills) do
        print(skill.name, skill.level, skill.xp)
    end
end)

Return Types

Boolean Returns

Many exports return boolean for success/failure:

-- Success
exports.dime_skills:addEXP(source, 'mining', 10)  -- returns true

-- Failure
exports.dime_skills:addEXP(source, 'invalid_skill', 10)  -- returns false

Nil Returns

Some exports return nil when data not found:

local skill = exports.dime_skills:getSkill('invalid')  -- returns nil

if not skill then
    print('Skill not found')
end

Usage Examples

Type Checking

-- Check if skill data is valid
local function isValidSkillData(data)
    return type(data) == 'table' and
           type(data.level) == 'number' and
           type(data.xp) == 'number'
end

local skill = exports.dime_skills:grabSkill(source, 'crafting')
if isValidSkillData(skill) then
    -- Safe to use
    print('Level:', skill.level)
end

Safe Access

-- Safely access optional fields
local skillConfig = config.skills['crafting']

if skillConfig and skillConfig.job then
    print('Job required:', skillConfig.job)
end

if skillConfig and skillConfig.action and skillConfig.action.event then
    print('Level-up event:', skillConfig.action.event)
end

Type Conversions

-- Ensure correct types
local function grantXP(source, skill, amount)
    -- Convert to numbers
    local xp = tonumber(amount)
    
    if not xp or xp <= 0 then
        return false
    end
    
    return exports.dime_skills:addEXP(source, skill, xp)
end

Common Patterns

Null Safety

local skill = exports.dime_skills:grabSkill(source, 'crafting')

-- Check before using
if not skill then
    print('Skill not found')
    return
end

-- Safe to access
local level = skill.level

Default Values

local function getSkillLevel(source, skillName)
    local skill = exports.dime_skills:grabSkill(source, skillName)
    return skill and skill.level or 1  -- Default to level 1
end

Table Operations

-- Iterate over all skills
local skills = exports.dime_skills:grabSkills(source)

if skills then
    for skillName, skillData in pairs(skills) do
        print(skillName, skillData.level)
    end
end