Client Events
Client-side events for Dime Skills
Client Events
All client-side events that can be triggered or listened to in Dime Skills.
These events are primarily for internal use and integration. Modify with caution.
dime_skills:openmenu
Opens the skills UI for the local player.
TriggerEvent('dime_skills:openmenu')Parameters
None
Example
-- Simple trigger
TriggerEvent('dime_skills:openmenu')
-- From server
TriggerClientEvent('dime_skills:openmenu', source)
-- In a command
RegisterCommand('showskills', function()
TriggerEvent('dime_skills:openmenu')
end)
-- Integrated with menu system
RegisterNetEvent('mymenu:openSkills', function()
TriggerEvent('dime_skills:openmenu')
end)Usage
Use this event when:
- Creating custom keybinds
- Integrating with menu systems
- Triggering from server
- Creating alternative access methods
This event is the same as calling exports.dime_skills:openUI(). Use whichever you prefer.
dime_skills:skillNotify
Displays a skill notification showing XP gain or loss.
TriggerEvent('dime_skills:skillNotify', data)Parameters
data(table): Notification data object
Data Structure:
{
skillName = 'Engineering', -- Skill display name
oldLevel = 5, -- Previous level
newLevel = 6, -- New level (or same)
oldPoints = 450.0, -- Previous XP
newPoints = 50.0, -- New XP
oldProgress = 75.0, -- Previous progress %
newProgress = 8.3, -- New progress %
requiredXPForOldLevel = 600, -- XP needed for old level
requiredXPForNewLevel = 700, -- XP needed for new level
bonusMultiplier = 1.0, -- Applied multiplier
icon = 'tools', -- FontAwesome icon
iconColor = '#3B82F6', -- Optional hex color
change = true -- true = gain, false = loss
}Example
-- Listen to skill notifications
RegisterNetEvent('dime_skills:skillNotify', function(data)
if data.change then
print('Gained XP in', data.skillName)
else
print('Lost XP in', data.skillName)
end
-- Check for level up
if data.newLevel > data.oldLevel then
print('LEVEL UP! Now level', data.newLevel)
-- Trigger custom effects
TriggerEvent('myresource:levelUpEffects', data.skillName, data.newLevel)
end
end)
-- Custom notification handling
RegisterNetEvent('dime_skills:skillNotify', function(data)
-- Override default notification with custom one
if data.newLevel > data.oldLevel then
-- Show special level-up notification
TriggerEvent('mytheme:showLevelUp', {
skill = data.skillName,
level = data.newLevel,
icon = data.icon
})
end
end)Notification Types
The notification display varies based on config.skillNotify:
UI Mode:
- Shows popup notification in UI
- Includes skill name, level, and XP change
- Progress bar visualization
- Auto-dismisses after timeout
ox_lib Mode:
- Uses ox_lib notify system
- Shows detailed XP information
- Includes icon (if provided)
- Standard ox_lib notification styling
Usage
This event is automatically triggered by:
- Server when XP is added/removed
- Skill level changes
- XP degradation
You can hook into it for:
- Custom notification systems
- Level-up effects
- Statistics tracking
- Achievement systems
Players can disable notifications using /togglenotifyskills command.
dime_skills:registerSkill
Registers a new skill configuration on the client.
RegisterNetEvent('dime_skills:registerSkill', function(name, data) end)Parameters
name(string): Skill identifierdata(table): Skill configuration object
Data Structure:
{
visuals = {
label = 'Skill Name',
description = 'Description',
category = 'Category',
icon = 'icon-name',
iconColor = '#hex'
},
levels = {
lvlMulti = { default = 2.5 },
lvlMax = 30,
degrade = {
enable = false,
timer = 168,
amount = 10
}
},
rewardMax = 50,
reduceMax = 50,
action = { ... },
job = 'job_name'
}Example
-- Listen for skill registration
RegisterNetEvent('dime_skills:registerSkill', function(name, data)
print(('New skill registered: %s (%s)'):format(name, data.visuals.label))
-- Update custom UI if needed
TriggerEvent('myui:addSkill', name, data)
end)
-- Track registered skills
local registeredSkills = {}
RegisterNetEvent('dime_skills:registerSkill', function(name, data)
registeredSkills[name] = data
print(('Total skills: %d'):format(#registeredSkills))
end)Usage
This event is triggered automatically when:
- Server calls
exports.dime_skills:addSkill() - Player logs in (syncs all skills)
- Resource starts
Use this for:
- Syncing skill data with custom UIs
- Tracking available skills
- Dynamic UI updates
- Integration with other resources
This is an internal synchronization event. Don't manually trigger it unless you know what you're doing.
dime_skills:divinglevelup
Handles diving skill level up while player is underwater.
RegisterNetEvent('dime_skills:divinglevelup', function() end)Parameters
None
Example
-- Listen for diving level ups
RegisterNetEvent('dime_skills:divinglevelup', function()
print('Diving skill increased!')
-- Wait until player surfaces
while IsPedSwimmingUnderWater(PlayerPedId()) or LocalPlayer.state.invBusy do
Wait(10)
end
-- Update diving parameters
-- (handled automatically by the event)
end)Behavior
When triggered:
- Waits for player to surface or inventory to close
- Recalculates oxygen capacity
- Updates diving parameters
- Applies new skill effects
Usage
This event is automatically triggered by the server when a player levels up their diving skill. It ensures diving parameters are properly updated even if the player is currently underwater.
You typically don't need to listen to or trigger this event unless:
- Creating custom diving systems
- Tracking diving progression
- Adding special effects on diving level up
dime_skills:sendPlayerSkills
Updates the client's skill data.
RegisterNetEvent('dime_skills:sendPlayerSkills', function(skills) end)Parameters
skills(table): Complete player skills table
Skills Structure:
{
['skill_name'] = {
level = 5,
xp = 234.5,
statlevel = 25.0,
lastupdated = 1234567890
},
-- ... more skills
}Example
-- Listen for skill updates
RegisterNetEvent('dime_skills:sendPlayerSkills', function(skills)
print('Skills updated!')
for skillName, skillData in pairs(skills) do
print(('%s: Level %d, XP: %.1f'):format(skillName, skillData.level, skillData.xp))
end
-- Update custom UI
TriggerEvent('myui:updateSkills', skills)
end)
-- Track skill changes
local previousSkills = {}
RegisterNetEvent('dime_skills:sendPlayerSkills', function(skills)
for skillName, skillData in pairs(skills) do
local prev = previousSkills[skillName]
if prev and prev.level < skillData.level then
print(('%s leveled up! %d -> %d'):format(skillName, prev.level, skillData.level))
end
end
previousSkills = skills
end)When Triggered
This event is sent by the server when:
- Player logs in
- Skill XP is added/removed
- Skill level changes
- Skill data is modified
- Manual skill updates
Usage
Use this event for:
- Syncing skill data with custom systems
- Updating custom UIs
- Tracking skill progression
- Analytics and statistics
This event provides the complete skill data. The UI and built-in systems automatically update when this is received.
dime_skills:viewOtherSkills
Opens the skills UI showing another player's skills.
RegisterNetEvent('dime_skills:viewOtherSkills', function(serverid) end)Parameters
serverid(number): Target player's server ID
Example
-- Triggered from server
RegisterNetEvent('admin:viewPlayerSkills', function(targetId)
TriggerEvent('dime_skills:viewOtherSkills', targetId)
end)
-- With ox_target
exports.ox_target:addGlobalPlayer({
{
name = 'view_player_skills',
label = 'View Skills',
icon = 'fa-solid fa-chart-line',
canInteract = function(entity, distance, coords, name, bone)
-- Add permission check here
return true
end,
onSelect = function(data)
local targetId = GetPlayerServerId(NetworkGetPlayerIndexFromPed(data.entity))
TriggerEvent('dime_skills:viewOtherSkills', targetId)
end
}
})
-- From menu system
RegisterNetEvent('playermenu:viewskills', function(targetId)
TriggerEvent('dime_skills:viewOtherSkills', targetId)
end)Behavior
When triggered:
- Requests skill data from server
- Opens skills UI in "viewing" mode
- Shows target player's skills
- Read-only view (can't modify)
Usage
Use this event for:
- Admin tools
- Player inspection
- Roleplay scenarios
- Job applications
- Showing credentials
This is equivalent to calling exports.dime_skills:viewSkills(serverid).
Usage Examples
Custom Level-Up Effects
-- Add visual effects on level up
RegisterNetEvent('dime_skills:skillNotify', function(data)
if data.newLevel > data.oldLevel then
-- Play sound
PlaySoundFrontend(-1, 'RANK_UP', 'HUD_AWARDS', false)
-- Show particle effect
TriggerServerEvent('myresource:levelUpEffect', data.skillName, data.newLevel)
-- Show custom notification
lib.notify({
title = '🎉 Level Up!',
description = ('%s reached level %d'):format(data.skillName, data.newLevel),
type = 'success',
duration = 5000
})
end
end)Skill-Based UI Integration
-- Update custom HUD with skill data
local currentSkills = {}
RegisterNetEvent('dime_skills:sendPlayerSkills', function(skills)
currentSkills = skills
-- Send to NUI
SendNUIMessage({
action = 'updateSkills',
data = {
crafting = skills.crafting,
driving = skills.driving,
shooting = skills.shooting
}
})
end)
-- Periodic HUD update
CreateThread(function()
while true do
if next(currentSkills) then
-- Update mini skill display
TriggerEvent('hud:updateSkills', currentSkills)
end
Wait(5000)
end
end)Achievement System Integration
-- Track achievements based on skill milestones
local achievementMilestones = {
crafting = { 10, 25, 50 },
shooting = { 15, 30 },
driving = { 20, 40 }
}
RegisterNetEvent('dime_skills:skillNotify', function(data)
if data.newLevel > data.oldLevel then
local milestones = achievementMilestones[data.skillName]
if milestones then
for _, milestone in ipairs(milestones) do
if data.newLevel == milestone then
TriggerServerEvent('achievements:unlock', 'skill_' .. data.skillName .. '_' .. milestone)
break
end
end
end
end
end)Custom Skill Display
-- Create custom skill display command
RegisterCommand('checkskill', function(_, args)
local skillName = args[1]
if not skillName then
print('Usage: /checkskill <skill_name>')
return
end
local skill = exports.dime_skills:getSkill(skillName)
local skillLabel = exports.dime_skills:getSkillName(skillName)
if skill and skillLabel then
lib.notify({
title = skillLabel,
description = ('Level: %d | XP: %.1f'):format(skill.level, skill.xp),
icon = 'chart-line'
})
else
lib.notify({
type = 'error',
description = 'Skill not found'
})
end
end)Best Practices
Event Handling
- Check Data Validity: Always validate event parameters
- Avoid Loops: Don't trigger events in tight loops
- Use Exports: Prefer exports over events when available
- Error Handling: Wrap event handlers in pcall for safety
Performance
- Efficient Handlers: Keep event handlers lightweight
- Debounce Updates: Don't update UI on every event
- Cache Data: Store skill data locally when needed
- Cleanup: Remove event handlers when no longer needed
Integration
- Permission Checks: Validate permissions before showing other players' skills
- UI Updates: Batch UI updates when possible
- State Management: Keep local state in sync with events
- Testing: Test event flow thoroughly
Related
- Server Events - Server-side events
- Client Exports - Client functions
- Configuration - Config options