Inicio › Documentación › Personalización · origen_reports

Personalización · origen_reports

text
custom/
└── server.lua

custom/** figura en escrow_ignore, así que es totalmente editable. Todas las funciones se ejecutan en el servidor y leen los valores autodetectados de Config.Framework, Config.Inventory, Config.Clothing y Config.Ambulance. Añade una rama nueva cuando tu recurso no sea compatible de serie.

Con ox_inventory, el listado de objetos, la entrega de objetos y la apertura de inventarios los gestiona internamente el recurso. Custom.getItemList, Custom.giveItem y Custom.openPlayerInventory no se llaman nunca en ese caso, así que editarlas no tiene ningún efecto.


custom/server.lua

Custom.getIdentifier(source) → string | nil

Devuelve el identificador único que se usa para guardar los reportes y las estadísticas del staff. Se llama cada vez que un jugador crea un reporte o se resuelve un miembro del staff.

Framework Valor devuelto
qb-core / qbx_core PlayerData.citizenid
esx xPlayer.getIdentifier()
Ninguno El identificador license
lua
Custom.getIdentifier = function(source)
    local player = getFrameworkPlayer(source)
 
    if Config.Framework == 'qb-core' or Config.Framework == 'qbx_core' then
        return player and player.PlayerData and player.PlayerData.citizenid or nil
    elseif Config.Framework == 'esx' then
        return player and player.getIdentifier and player.getIdentifier() or nil
    end
 
    return GetPlayerIdentifierByType(source, 'license')
end

Cambiar el formato del identificador después de haber usado el recurso deja huérfanos los reportes y las estadísticas del staff existentes, ya que se indexan por este valor.


Custom.hasConfigFullAccess(source) → boolean

Devuelve true cuando el jugador coincide con algún permiso de Config.StaffFullAccess.

Custom.hasConfigBasicAccess(source) → boolean

Devuelve true cuando el jugador coincide con algún permiso de Config.StaffBasicAccess.

Ambas pasan por la misma comprobación interna, aplicada a cada permiso de la lista:

  1. ACE <permission> o group.<permission>.
  2. qbx_core — exports.qbx_core:HasPermission y GetPermission.
  3. qb-core — Framework.Functions.GetPermission.
  4. esx — xPlayer.getGroup() == permission.

Sobrescríbelas para integrar un sistema de permisos propio:

lua
Custom.hasConfigFullAccess = function(source)
    return exports['my_admin']:IsAdmin(source)
end
 
Custom.hasConfigBasicAccess = function(source)
    return exports['my_admin']:IsModerator(source)
end
Parámetro Tipo Descripción
source number ID de servidor del jugador

Custom.getStaffLevel(source) → 'full' | 'basic' | false

Resuelve el nivel de acceso de un jugador a partir de las dos funciones anteriores. Si coinciden ambas, prevalece el acceso completo. Devuelve false cuando el jugador no es staff por configuración (aun así puede ser staff limitado si se le añadió con un grupo desde el panel de administración).

lua
Custom.getStaffLevel = function(source)
    local hasBasic = Custom.hasConfigBasicAccess(source)
    local hasFull = Custom.hasConfigFullAccess(source)
 
    if hasBasic and hasFull then
        return 'full'
    end
 
    if hasBasic then
        return 'basic'
    end
 
    if hasFull then
        return 'full'
    end
 
    return false
end

Custom.getItemList() → table

Devuelve todos los objetos registrados como { name, label }, ordenados por etiqueta. Se usa para rellenar el selector de objetos de la acción rápida dar objetos y la lista de objetos permitidos de los grupos de staff.

Inventario Origen
qb-inventory / ps-inventory Framework.Shared.Items
codem-inventory exports['codem-inventory']:GetItemList()
qs-inventory exports['qs-inventory']:GetItemList()
origen_inventory exports.origen_inventory:Items()
core_inventory Framework.Shared.Items, o Framework.Items() en ESX
tgiann-inventory exports['tgiann-inventory']:GetItemList()
Cualquier otro Framework.Shared.Items, o Framework.Items() en ESX

Para añadir un inventario, devuelve su tabla de objetos a través de la función auxiliar local mapItemTable:

lua
elseif Config.Inventory == 'my_inventory' then
    return mapItemTable(exports['my_inventory']:GetItemList())

Custom.giveItem(source, item, count) → boolean

Da un objeto al jugador reportado. Lo llama la acción rápida dar objetos. Por convención devuelve true si todo va bien, aunque el recurso no lee el valor devuelto.

Parámetro Tipo Descripción
source number ID de servidor del jugador que recibe el objeto
item string Nombre del objeto
count number Cantidad a dar

qs-inventory y tgiann-inventory comprueban primero CanCarryItem y devuelven false cuando el jugador no puede cargarlo. Los inventarios sin rama propia recurren al framework: Functions.AddItem en QB/Qbox y addInventoryItem en ESX.

lua
elseif Config.Inventory == 'my_inventory' then
    if not exports['my_inventory']:CanCarryItem(source, item, count) then return false end
    return exports['my_inventory']:AddItem(source, item, count)

Custom.openPlayerInventory(source, target) → boolean

Abre al miembro del staff el inventario del jugador reportado. Lo llama la acción rápida inventario. Devuelve false cuando el inventario no es compatible.

Parámetro Tipo Descripción
source number ID de servidor del miembro del staff
target number ID de servidor del jugador cuyo inventario se abre
Inventario Llamada
qb-inventory OpenInventory(source, target)
ps-inventory OpenInventoryById(source, target)
origen_inventory OpenInventory(source, 'otherplayer', target)
core_inventory openInventory(source, 'stash-<identifier>', 'stash', ...)
tgiann-inventory OpenInventoryById(source, target)
jpr-inventory OpenInventory(source, identifier)

qs-inventory y codem-inventory no tienen rama aquí, así que la acción rápida inventario devuelve false con ellos. Añade su llamada de apertura si usas alguno de los dos.


Custom.openClothingMenu(source) → boolean

Abre el menú de ropa al jugador reportado. Lo llama la acción rápida ropa.

Ropa Evento de cliente
illenium-appearance illenium-appearance:client:openClothingShopMenu
esx_skin esx_skin:openMenu
qb-clothing / fivem-appearance / rcore_clothing qb-clothing:client:openMenu
origen_clothing origen_clothing:client:openOutfitMenu
lua
elseif Config.Clothing == 'my_clothing' then
    TriggerClientEvent('my_clothing:client:openMenu', source)
    return true

Custom.revivePlayer(source) → boolean

Reanima al jugador reportado. Lo llama la acción rápida reanimar.

Ambulancia Llamada
qb-ambulancejob / qbx_medical Evento de cliente hospital:client:Revive
esx_ambulancejob Evento de servidor esx_ambulancejob:revive
wasabi_ambulance Evento de servidor wasabi_ambulance:revivePlayer
Ninguna en ESX Evento de servidor esx_ambulancejob:revive
Ninguna en QB/Qbox Evento de cliente hospital:client:Revive
lua
elseif Config.Ambulance == 'my_ambulance' then
    TriggerClientEvent('my_ambulance:client:revive', source)
    return true
Parámetro Tipo Descripción
source number ID de servidor del jugador a reanimar