Command Palette
Search for a command to run...
SERVER EXPORTS#
Server exports allow you to interact with onex-creation from server-side scripts, including appearance management and data migration.
Format Detection#
DetectFormat#
Detect the format of appearance data on the server.
local format = exports['onex-creation']:DetectFormat(data)
Parameters:
| Name | Type | Description |
|---|---|---|
data | table | Appearance data to analyze |
Returns: string - Detected format type
Supported Formats:
'schema_v2'- onex-creation Schema v2'qb-clothing'- QBCore clothing format'esx_skin'- ESX skin format'fivem-appearance'- FiveM Appearance format'illenium-appearance'- Illenium Appearance format'onex-legacy'- Legacy onex format
Example:
Server Scriptlocal playerData = GetPlayerAppearanceFromYourDB(source) local format = exports['onex-creation']:DetectFormat(playerData) if format == 'schema_v2' then print('Already in correct format') elseif format == 'qb-clothing' then print('Needs migration from QB format') end
Migration#
MigrateAppearance#
Migrate appearance data from legacy formats to Schema v2.
local result = exports['onex-creation']:MigrateAppearance(identifier, rawData, source)
Parameters:
| Name | Type | Description |
|---|---|---|
identifier | string | Player identifier |
rawData | table | Raw appearance data in any supported format |
source | number | Player source ID |
Returns: table - Migration result
{ success = true/false, appearance = { ... }, -- Converted appearance originalFormat = 'qb-clothing', errors = {} -- Any errors during migration }
Example:
Server Scriptlocal oldData = { ["pants"] = { item = 10, texture = 0 }, ["arms"] = { item = 15, texture = 0 } } local result = exports['onex-creation']:MigrateAppearance( 'license:abc123', oldData, source ) if result.success then print('Migrated from:', result.originalFormat) -- result.appearance is now Schema v2 else print('Migration failed:', json.encode(result.errors)) end
FullMigration#
Perform a complete migration including database update.
local result = exports['onex-creation']:FullMigration(identifier, rawData, source)
Parameters:
| Name | Type | Description |
|---|---|---|
identifier | string | Player identifier |
rawData | table | Raw appearance data |
source | number | Player source ID |
Returns: table - Migration result with database update status
Example:
Server Script-- Migrate and save to database local result = exports['onex-creation']:FullMigration( identifier, oldAppearance, source ) if result.success then print('Migration complete, database updated') TriggerClientEvent('onex-creation:client:loadPedSkin', source, result.appearance) end
Database Operations (Standalone Only)#
onxquerys#
Access the database query system.
local db = exports['onex-creation']:onxquerys()
Returns: table - Database query functions
Available Functions:
| Function | Description |
|---|---|
db.fetchAppearance(identifier) | Get player appearance |
db.saveAppearance(identifier, appearance) | Save player appearance |
db.fetchOutfits(identifier) | Get player outfits |
db.saveOutfit(identifier, outfit) | Save outfit |
db.deleteOutfit(identifier, outfitId) | Delete outfit |
Example:
Server Scriptlocal db = exports['onex-creation']:onxquerys() -- Fetch player appearance local appearance = db.fetchAppearance('license:abc123') -- Save appearance db.saveAppearance('license:abc123', newAppearance) -- Fetch outfits local outfits = db.fetchOutfits('license:abc123') for _, outfit in ipairs(outfits) do print('Outfit:', outfit.outfitname) end
Schema Utilities#
GetSchema#
Get the component schema definitions.
local schema = exports['onex-creation']:GetSchema()
Returns: table - Complete schema definitions
Example:
Server Scriptlocal schema = exports['onex-creation']:GetSchema() -- Get component info print('Components:', json.encode(schema.components)) print('Props:', json.encode(schema.props))
ValidateAppearance#
Validate appearance data against the schema.
local isValid = exports['onex-creation']:ValidateAppearance(appearance)
Parameters:
| Name | Type | Description |
|---|---|---|
appearance | table | Appearance data to validate |
Returns: boolean - Whether the appearance is valid
Example:
Server Scriptlocal appearance = GetPlayerAppearance(source) if exports['onex-creation']:ValidateAppearance(appearance) then print('Appearance is valid') else print('Appearance has invalid data') end
CreateDefaultAppearance#
Create a default appearance for a model.
local appearance = exports['onex-creation']:CreateDefaultAppearance(model)
Parameters:
| Name | Type | Description |
|---|---|---|
model | string | Ped model name |
Returns: table - Default appearance for the model
Example:
Server Script-- Create default male appearance local maleDefault = exports['onex-creation']:CreateDefaultAppearance('mp_m_freemode_01') -- Create default female appearance local femaleDefault = exports['onex-creation']:CreateDefaultAppearance('mp_f_freemode_01') -- Use for new characters TriggerClientEvent('onex-creation:client:loadPedSkin', source, maleDefault)
GetColorPalette#
Get the color palette for a component.
local palette = exports['onex-creation']:GetColorPalette(componentKey)
Parameters:
| Name | Type | Description |
|---|---|---|
componentKey | string | Component category name |
Returns: table - Available colors
Example:
Server Script-- Get hair colors local hairColors = exports['onex-creation']:GetColorPalette('hair') -- Get makeup colors local makeupColors = exports['onex-creation']:GetColorPalette('makeup')
Usage Examples#
Custom Admin Panel#
Server ScriptRegisterCommand('adminsetclothes', function(source, args) local targetId = tonumber(args[1]) if not targetId then return end -- Create appearance local appearance = exports['onex-creation']:CreateDefaultAppearance('mp_m_freemode_01') -- Modify it appearance.components["11"] = { collection = "base", localIndex = 55, texture = 0 } -- Validate if exports['onex-creation']:ValidateAppearance(appearance) then -- Apply to target TriggerClientEvent('onex-creation:client:loadPedSkin', targetId, appearance) end end, true)
Bulk Migration Script#
Note for Developers: This export is typically not required as onex-creation automatically handles migration when players join the server. Use this only for advanced scenarios like pre-migrating an entire database before deployment or custom migration workflows.
Server ScriptRegisterCommand('migrateall', function(source) local players = MySQL.query.await('SELECT identifier, skin FROM users WHERE skin IS NOT NULL') local migrated = 0 local failed = 0 for _, player in ipairs(players) do local oldSkin = json.decode(player.skin) local result = exports['onex-creation']:MigrateAppearance( player.identifier, oldSkin, 0 ) if result.success then -- Update database MySQL.update.await( 'UPDATE users SET skin = ? WHERE identifier = ?', { json.encode(result.appearance), player.identifier } ) migrated = migrated + 1 else failed = failed + 1 print('Failed to migrate:', player.identifier) end end print(string.format('Migration complete: %d migrated, %d failed', migrated, failed)) end, true)