Inicio › Documentación › Personalización · origen_chat

Personalización · origen_chat

La carpeta custom/ te permite integrar cualquier framework, sistema de notificaciones o filtro del chat sin tocar el núcleo. Todos los ficheros son escrow_ignore, así que se conservan al actualizar.

text
custom/
├── client/
│   ├── framework.lua   — player job (client-side)
│   ├── notify.lua      — notifications
│   └── chat.lua        — chat open gate, raw message hook
└── server/
    ├── framework.lua   — player identifier, name, job, group
    └── permissions.lua — permission check

custom/client/framework.lua

Custom.GetPlayerJob() → { name, label?, grade: { name, level } }

Devuelve el trabajo actual del jugador local. Delega en Config.Framework.

lua
Custom.GetPlayerJob = function()
    -- 'qb-core' / 'qbx_core' → Framework.Functions.GetPlayerData().job
    -- 'esx'                   → Framework.GetPlayerData().job (normalized)
    -- 'standalone'            → { name = 'unknown', grade = { name = 'unknown', level = 0 } }
end

custom/client/notify.lua

Custom.Notify(text, type, length)

Muestra una notificación al jugador local. Se llama cuando Config.CustomNotify = true.

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

custom/client/chat.lua

Custom.CanOpenChat() → boolean

Controla si el jugador local puede abrir la entrada del chat. Devuelve false para bloquearla (p. ej. durante una cinemática).

lua
Custom.CanOpenChat = function()
    return true
end

Custom.OnSendNoCommandMessage(playerId, message)

Se llama cuando un jugador envía un mensaje que no empieza por /. Implementa aquí tu propio gestor de mensajes sin comando.

lua
Custom.OnSendNoCommandMessage = function(playerId, message)
    -- Example: route to a default /say command
    -- TriggerServerEvent('origen_chat:server:say', message)
end

custom/server/framework.lua

Función Devuelve Descripción
Custom.GetIdentifier(source) string | nil Identificador único del jugador
Custom.GetPlayerName(source) string Nombre completo del jugador o 'Unknown'
Custom.GetPlayerJob(source) { name, label, grade } Trabajo y rango del jugador
Custom.GetGroup(source) string | table Grupo de permisos del jugador

Todas las funciones delegan automáticamente según Config.Framework (qb-core, qbx_core, esx, standalone).


custom/server/permissions.lua

Custom.hasPermission(source, permissions) → boolean, string

Comprueba si un jugador pertenece a alguno de los grupos de permisos indicados. Lo usan los comandos que tienen el campo permissions en Config.Commands.

lua
Custom.hasPermission = function(source, permissions)
    -- permissions: array of group names (e.g. { 'admin', 'god' })
    -- returns: true if the player's group is in the list
end