Inicio › Documentación › Personalización · origen_radio
La carpeta custom/ contiene la capa de integración entre origen_radio y el resto de tu servidor. Estos ficheros no están protegidos por escrow y están pensados para editarse.
custom/
├── client/
│ └── client.lua ← Framework, inventory, pma-voice and revive integration
└── server/
└── server.lua ← Framework core object and notificationsGetCoreObject() → tableDevuelve el objeto core del framework activo.
-- QBCore
local Core = GetCoreObject()
-- ESX
local ESX = GetCoreObject()FW_Notify(text)Muestra una notificación al jugador local con el sistema de notificaciones del framework activo.
FW_Notify("You need a radio item.")| Parámetro | Tipo | Descripción |
|---|---|---|
text |
string |
Mensaje que se muestra |
OverrideProximityRange(distance, bool)Sobrescribe el rango de proximidad de pma-voice. Pasa nil para quitar la sobrescritura y restaurar el valor por defecto.
-- Override to 10 metres
OverrideProximityRange(10.0, true)
-- Clear the override
OverrideProximityRange(nil)| Parámetro | Tipo | Descripción |
|---|---|---|
distance |
number | nil |
Rango de proximidad deseado en metros, o nil para restablecerlo |
bool |
boolean |
Se pasa directamente a pma-voice:overrideProximityRange |
ToggleVoice(target, value, string)Llama a pma-voice:toggleVoice para el objetivo indicado.
ToggleVoice(target, true, "radio")PlayerTargets(radioFreqs)Llama a pma-voice:playerTargets con la lista actual de objetivos de frecuencias de radio.
PlayerTargets(Radio.Targets)IsPlayerDead() → booleanDevuelve true si el jugador local está reproduciendo la animación de muerte. Se usa internamente para impedir el uso de la radio estando muerto.
if IsPlayerDead() then return endCanTalk() → booleanFiltro personalizado que controla si el jugador puede transmitir. Devuelve false para bloquear la transmisión en cualquier circunstancia (p. ej. esposado, dentro de un vehículo, etc.).
function CanTalk()
-- Add your logic here
return true
endCanOpenRadio() → booleanFiltro personalizado que controla si el jugador puede abrir la NUI de la radio. Devuelve false para impedir la apertura en cualquier circunstancia.
function CanOpenRadio()
-- Add your logic here
return true
endGetPlayerItems(PlayerData) → tableDevuelve los objetos del inventario del jugador para el recurso de inventario activo. Esta función se usa internamente para comprobar si el jugador lleva un objeto de radio cuando Config.NeedRadioItem es true.
La implementación ya cubre todos los inventarios compatibles. Añade un bloque elseif aquí si usas un inventario no compatible.
function GetPlayerItems(PlayerData)
if Config.Inventory == "ox_inventory" then
return exports.ox_inventory:GetPlayerItems()
end
-- ...
return PlayerData.items or {}
endSi Config.CustomReviveEvent está definido, custom/client/client.lua registra automáticamente un listener para ese evento y reactiva la radio al reanimar; no hace falta código adicional.
GetCoreObject() → tableDevuelve el objeto core del framework en el lado del servidor. Se usa internamente para resolver los datos del jugador.
local Core = GetCoreObject()FW_Notify(source, text)Envía una notificación a un jugador concreto con el sistema de notificaciones del framework activo.
FW_Notify(source, "You have been removed from the frequency.")| Parámetro | Tipo | Descripción |
|---|---|---|
source |
number |
ID de servidor del jugador |
text |
string |
Mensaje que se muestra |