Inicio › Documentación › Personalización · origen_garages

Personalización · origen_garages

La carpeta custom/ te permite integrar cualquier framework, sistema de notificaciones, sistema de combustible o sincronización del clima sin tocar el núcleo. Todos los ficheros de aquí son escrow_ignore: sobreviven a las actualizaciones.

text
custom/
├── client/
│   ├── framework.lua  — player identifier, job, gang, loaded state
│   ├── keys.lua       — give vehicle keys on retrieval
│   ├── fuel.lua       — get/set fuel level
│   ├── notify.lua     — notifications and text UI
│   └── weather.lua    — disable/enable weather sync inside interiors
└── server/
    └── framework.lua  — player identifier, job, money, permissions, name

custom/server/framework.lua

Framework.GetPlayerIdentifier(source) → string | nil

Devuelve el identificador único (citizenid / identifier) de un jugador en el servidor.

lua
Framework.GetPlayerIdentifier = function(source)
    -- Config.Framework == 'custom': implement here
end

Framework.GetPlayerJob(source) → { name, grade }

Devuelve el nombre del trabajo y el rango de un jugador.

lua
Framework.GetPlayerJob = function(source)
    -- returns { name = 'police', grade = 2 }
end

Framework.GetMoney(source) → number

Devuelve el saldo del jugador para Config.PaymentMethod.

lua
Framework.GetMoney = function(source)
    -- Config.PaymentMethod = 'bank' | 'cash'
end

Framework.RemoveMoney(source, account, amount) → boolean

Descuenta dinero de la cuenta del jugador. Devuelve true si se ha completado.

lua
Framework.RemoveMoney = function(source, account, amount)
end

Framework.HasPermission(source, group) → boolean

Comprueba si un jugador pertenece a un grupo de permisos. El panel de administración lo usa con Config.Permissions.

lua
Framework.HasPermission = function(source, group)
end

Framework.GetPlayerName(source) → string

Devuelve el nombre completo del jugador (nombre + apellido).

lua
Framework.GetPlayerName = function(source)
end

custom/client/framework.lua

Framework.GetPlayerIdentifier() → string | nil

Devuelve el identificador único del jugador local.

lua
Framework.GetPlayerIdentifier = function()
    -- Config.Framework == 'custom': implement here
end

Framework.GetPlayerJob() → { name, grade }

Devuelve el trabajo actual del jugador local.

lua
Framework.GetPlayerJob = function()
    return { name = 'unknown', grade = 0 }
end

Framework.GetPlayerGang() → { name, grade }

Devuelve la banda actual del jugador local. Por defecto devuelve unknown.

lua
Framework.GetPlayerGang = function()
    return { name = 'unknown', grade = 0 }
end

Framework.isPlayerLoaded() → boolean

Devuelve true cuando los datos del jugador están listos y cargados.

lua
Framework.isPlayerLoaded = function()
    return false -- replace with your check
end

custom/client/keys.lua

Custom.GiveVehicleKeys(vehicle, plate)

Da las llaves del vehículo al jugador local después de sacarlo. Implementa aquí tu sistema de llaves.

lua
Custom.GiveVehicleKeys = function(vehicle, plate)
    -- Example with qbx_vehiclekeys:
    -- exports['qbx_vehiclekeys']:GiveKeys(vehicle, true)
end

custom/client/fuel.lua

Custom.GetFuel / Custom.SetFuel

Por defecto ambas valen false (desactivadas: se usa el combustible nativo). Asígnales funciones para usar un sistema de combustible propio:

lua
Custom.GetFuel = function(vehicle)
    return exports['fuel-system']:GetFuel(vehicle)
end
 
Custom.SetFuel = function(vehicle, fuelLevel)
    exports['fuel-system']:SetFuel(vehicle, fuelLevel)
end

custom/client/notify.lua

Custom.Notify(text, type, length)

Muestra una notificación al jugador local.

lua
Custom.Notify = function(text, type, length)
    lib.notify({
        description = text,
        type        = type,     -- 'info' | 'success' | 'error'
        duration    = length,
    })
end

Custom.DrawText(text, key)

Muestra una ayuda de interacción en la interfaz de texto.

lua
Custom.DrawText = function(text, key)
    lib.showTextUI('[' .. key .. '] - ' .. text)
end

Custom.HideText()

Oculta la ayuda de interacción.

lua
Custom.HideText = function()
    lib.hideTextUI()
end

custom/client/weather.lua

Custom.DisableWeatherSync() / Custom.EnableWeatherSync()

Se llaman cuando el jugador entra o sale de un interior de garaje. Úsalas para pausar o reanudar tu recurso de sincronización del clima y que no sobrescriba el clima estático del interior.

lua
Custom.DisableWeatherSync = function()
    -- Example: TriggerEvent('your_weather:pause')
end
 
Custom.EnableWeatherSync = function()
    -- Example: TriggerEvent('your_weather:resume')
end