Skip to content

nxn-sirencontrol: Új script – Szélsőséges jármű fény/hang kezelés, egyedi siren panelek, nxn-police/dispatch integráció #173

Description

@firstvideosgrp

📋 Összefoglalás

Az nxn-sirencontrol a Nexon RP szerver sugárzó jármű szimatolás-menó, lámpa és szimulatort kezelő rendszere. Teljes körű irányítást biztosít a szükség járművek (rendőrségi, mentő, tűzoltó) kékfényes/hang-szimt rendszerén és azt animalizálja. A script GTA V natív hangmotor helyett egyedi, konfigurálható szédülés-sémiák használatával működik, és támogatja a multi-tónus viszonylagos kapcsolást (horn, wail, yelp, priority stb.), az egyedi fényrendszer irányítást és több járműmodellre specifikált konfigurációt.

⚠️ Fontos hatásköri lehatárolás:

  • nxn-sirencontrolSzédülés tónus választás, lámpa-módok, panelkezelés, jármű-specifikus hangkészletek
  • nxn-police → Duty, fegyver, arrest rendszer – nem kezeli a szimt rendszert
  • nxn-dispatch → Hívás létrehozás automatikusan, amikor a szimt aktivitálódik (config kapcsolható)
  • nxn-needs → szimt szédülés stressz hatása (régi kék fény használat)
  • nxn-hud → aktiv szédülés állapot badge megjelenítése

🔗 Hivatkozások a korábbi issue-kban

Issue Hivatkozás
#158 – nxn-police A rendőrségi járművek kontéxusában szinezd az nxn-sirencontrol exportjait használja (isSirenActive, getSirenMode)
#167 – nxn-dispatch Szimt aktiválásakor opcionálisan createCall export hívás

🔗 Kapcsolódó scriptek

Script Kapcsolat
nxn-police OpcionálisisSirenActive(src), getSirenMode(src) exportok olvasása rendőrségi logikához
nxn-dispatch Opcionális – szimt bekapcsolásakor automatikus createCall (ha Config.AutoDispatch = true)
nxn-needs Opcionális – aktiv kékfény használatakor környékbeli NPC/játékos stressz növelés
nxn-hud Opcionális – aktiv szimt badge a HUD-on (updateModuleData)
nxn-duty Opcionális – csak duty-ban lévők aktivizlhatják (ha Config.RequireDuty = true)
nxn-loading updateModuleProgress('SirenControl', 100) betöltéskor

🏗️ Fájlstruktúra

nxn-sirencontrol/
├── fxmanifest.lua
├── config.lua
├── shared.lua
├── client.lua
├── server.lua
├── html/
│   ├── index.html      -- Siren panel NUI
│   ├── style.css
│   └── app.js
└── docs/index.html

Sablon: nxn-example boilerplate, dizájn: design-guide.html


⚙️ config.lua

Config = {}

Config.ResourceName = GetCurrentResourceName()
Config.Debug        = false

-- Duty követelmény (nxn-duty integráció)
-- Ha true: csak az aktivizlhatja a szirmt, akinek van aktiv duty-ja a megfelelő frakcióban
Config.RequireDuty   = true
Config.DutyFactions  = { 'police', 'sheriff', 'ems', 'fire' }  -- ezekhez engedélyezett

-- Auto dispatch (nxn-dispatch)
-- Ha true: szimt bekapcsolásakor automatikusan létrehoz egy dispatch hívást
Config.AutoDispatch         = false
Config.AutoDispatchType     = 'general_police'  -- dispatch call type
Config.AutoDispatchCooldown = 300               -- mp: ennyi időn belül ne hozzon létre újat

-- Alap toggle billentyű (NUI nélkül: keybind alapú)
Config.KeyToggleSiren  = 'E'   -- szimt be/ki (csak ha járműben ül)
Config.KeyCycleTone    = 'Q'   -- szimt tónus váltás (cycle)
Config.KeyHorn         = 'R'   -- manuel kürt
Config.KeyToggleLights = 'F'   -- fény be/ki
Config.KeyOpenPanel    = 'Z'   -- NUI panel megnyitás

-- Szimt tónus sémák
-- Minden séma egy GTA V szimt minta azonosítóhoz (0-13) vagy egyedi audio bankhoz kötött
Config.SirenTones = {
    off = {
        id    = 'off',
        label = 'Ki',
        icon  = 'hgi-cancel-circle',
        sirenId = nil,
        hornId  = nil,
    },
    wail = {
        id    = 'wail',
        label = 'Wail',
        icon  = 'hgi-wave',
        sirenId = 1,
        hornId  = 1,
    },
    yelp = {
        id    = 'yelp',
        label = 'Yelp',
        icon  = 'hgi-wave-up',
        sirenId = 2,
        hornId  = 2,
    },
    priority = {
        id    = 'priority',
        label = 'Priority',
        icon  = 'hgi-alert-diamond',
        sirenId = 3,
        hornId  = 3,
    },
    airhorn = {
        id    = 'airhorn',
        label = 'Légkürt',
        icon  = 'hgi-megaphone',
        sirenId = nil,
        hornId  = 8,  -- csak kürt, szimt nem
    },
    manual = {
        id    = 'manual',
        label = 'Manuális',
        icon  = 'hgi-hand-point-right-02',
        sirenId = nil,
        hornId  = nil,
        isManual = true,  -- csak gomb lenyomáskor szól
    },
}

-- Tónus sorrend (cycle-hoz)
Config.ToneCycleOrder = { 'wail', 'yelp', 'priority', 'airhorn', 'manual', 'off' }

-- Fény módok
Config.LightModes = {
    off = {
        id    = 'off',
        label = 'Ki',
        icon  = 'hgi-sun-03',
        sirenLights = false,
        hazards     = false,
    },
    full = {
        id    = 'full',
        label = 'Teljes',
        icon  = 'hgi-sun-02',
        sirenLights = true,
        hazards     = false,
    },
    hazard = {
        id    = 'hazard',
        label = 'Veszélyfény',
        icon  = 'hgi-warning-triangle',
        sirenLights = false,
        hazards     = true,
    },
    silent = {
        id    = 'silent',
        label = 'Csendes (csak fény)',
        icon  = 'hgi-eye',
        sirenLights = true,
        hazards     = false,
        muteSound   = true,  -- fény megy, hang nem
    },
}

-- Jármű-specifikus konfigurációk
-- Ha egy modell itt szerepel, az itt megadott tónusok és fény módok felülírják az általánosat
Config.VehicleOverrides = {
    ambulance = {
        allowedTones  = { 'wail', 'yelp', 'airhorn', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'ems' },
    },
    firetruk = {
        allowedTones  = { 'wail', 'priority', 'airhorn', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'fire' },
    },
    police = {
        allowedTones  = { 'wail', 'yelp', 'priority', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'police', 'sheriff' },
    },
    police2 = {
        allowedTones  = { 'wail', 'yelp', 'priority', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'police', 'sheriff' },
    },
    sheriff = {
        allowedTones  = { 'wail', 'yelp', 'priority', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'sheriff' },
    },
    riot  = {
        allowedTones  = { 'wail', 'yelp', 'priority', 'manual', 'off' },
        defaultTone   = 'wail',
        defaultLights = 'full',
        factions      = { 'police' },
    },
}

-- Szimt hang hangereje (0.0 - 1.0)
Config.SirenVolume = 0.8

-- Szimt hálózati szinkronizálás: más játékosok is hallákják-e a szirmt
Config.NetworkSync = true
-- Szimt hálózati sugara (méter): ennyi távolságig hallatszik más játékosnál
Config.NetworkRange = 300.0

-- nxn-needs stressz (körülálló játékosoknak)
Config.NearbyStressRadius  = 50.0
Config.NearbyStressAmount  = 2
Config.NearbyStressInterval = 5000  -- ms

-- ACE
Config.AdminAce = 'nxn.sirencontrol.admin'

📡 Kliens exportok

Export Visszatérés Leírás
isSirenActive() boolean Aktiv-e a szimt (hang vagy fény bármilyen)
getSirenMode() table|nil Aktuális tónus és fény mód adatai ({ tone, lightMode, isMuted })
getSirenTone() string Aktuális tónus ID ('wail', 'yelp', 'off' stb.)
getLightMode() string Aktuális fény mód ID
getCurrentVehicle() number|nil Aktuális jármű entitás handle, amelyen a szimt fél fut
isInSirenVehicle() boolean Szimt-képes járműben ül-e a játékos
setSirenTone(toneId) boolean Programatikusan beállít egy tónust
setLightMode(modeId) boolean Programatikusan beállít egy fény módot
toggleSiren() boolean Toggle: ha ki volt, bekapcsolja az alapértelmezettet, ha be volt, kikapcsolja

📡 Szerver exportok

Export Paraméterek Visszatérés Leírés
isSirenActive(src) number boolean Játékos szimtéje aktiv-e (szerver cache)
getSirenState(src) number table|nil Játékos teljes szimt állapota (tónus, fény mód, jármű)
getSirenVehicle(src) number number|nil Aktiv szimt-es jármű network ID-ja
getActiveSirenPlayers() table[] Az összes aktiv szimt-es játékos listája

📡 Net eventek

Kliens → Szerver

nxn-sirencontrol:server:updateState  -- { tone, lightMode, vehicleNetId, model }
nxn-sirencontrol:server:sirenOff     -- {} (szimt leáll)

Szerver → Kliens

nxn-sirencontrol:client:forceOff     -- Admin: kényszerített szimt leállítás

Szerver lokál (más scriptek figyelhetik)

nxn-sirencontrol:server:sirenActivated   -- src, tone, lightMode, vehicleNetId
nxn-sirencontrol:server:sirenDeactivated -- src, vehicleNetId
nxn-sirencontrol:server:toneChanged      -- src, oldTone, newTone
nxn-sirencontrol:server:lightModeChanged -- src, oldMode, newMode

🔄 Működési folyamat

Indulás / jármű detectálás

Kliens thread (500ms):
    Játékos járműben ül és vezető székben van?
        ↓ IGEN
    GetEntityModel(vehicle) → modellnév
    Széred jármű? (Config.VehicleOverrides-ban szerepel?)
        ↓ IGEN: sirenVehicle = true, override = Config.VehicleOverrides[model]
        ↓ NEM: GetVehicleClass(vehicle) == 18? (Emergency)
            ↓ IGEN: sirenVehicle = true, override = nil (általános)
            ↓ NEM: sirenVehicle = false → NUI panel elrejtése, szimt ki
    Megváltozott-e a jármű?
        ↓ IGEN: resetSirenState(), NUI frissítés az új jármű adataival

Szimt tónus aktiválás

Játékos [E] gomb nyomás (vagy NUI panel gomb):
    Járműben van? sirenVehicle?
        ↓ IGEN
    Config.RequireDuty? → nxn-duty:isOnDuty() check
        ↓ OK
    currentTone == 'off'?
        ↓ IGEN: tone = defaultTone (jármű override vagy 'wail')
        ↓ NEM: tone = 'off'
    ApplySirenTone(vehicle, tone)
    TriggerServerEvent('nxn-sirencontrol:server:updateState', { tone, lightMode, vehicleNetId })
    SendNUIMessage({ action = 'updateState', tone, lightMode })

Szimt fény alkalmazás (GTA natív)

-- nxn-sirencontrol/client.lua:
local function ApplySirenTone(vehicle, toneId)
    local toneData = Config.SirenTones[toneId]
    if not toneData then return end

    local lightMode = Config.LightModes[currentLightMode or 'full']

    -- Fény
    SetVehicleSiren(vehicle, lightMode and lightMode.sirenLights or false)
    SetVehicleHazardLights(vehicle, lightMode and lightMode.hazards or false)

    -- Hang
    if toneId == 'off' or (lightMode and lightMode.muteSound) then
        -- Natív szimt hang kikapcsolása
        SetVehicleSiren(vehicle, false)
        -- Audio mock: ha egyedi szimt hangot játszottunk, állítsuk le
        StopCustomSiren()
    elseif toneData.isManual then
        -- Csak gomb lenyomáskor szól – kezelése külön (R gomb)
        currentTone = toneId
    else
        -- GTA natív szimt pattern ID beállítása
        -- SetVehicleSiren bekapcsol + szimt pattern:
        SetVehicleSiren(vehicle, true)
        -- Pattern beállítás (FiveM natív ha elérhető, különben audio bank hack)
        if toneData.sirenId then
            -- FiveM: SetVehicleSirenSound vagy audio bank trigger
            TriggerEvent('nxn-sirencontrol:client:applyAudioBank',
                vehicle, toneData.sirenId, toneData.hornId)
        end
    end

    currentTone = toneId
end

Hálózati szinkronizáció (más játékosok hallákják)

-- nxn-sirencontrol/client.lua:
-- Más játékosok szimtét figyeli és megfelelő hangot játszik le
AddEventHandler('nxn-sirencontrol:client:remoteStateUpdate', function(data)
    -- data: { srcNetId, vehicleNetId, tone, lightMode }
    if not Config.NetworkSync then return end

    local vehicle = NetToVeh(data.vehicleNetId)
    if not DoesEntityExist(vehicle) then return end

    local dist = #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(vehicle))
    if dist > Config.NetworkRange then return end

    -- Fény beállítás (mások látják)
    local lightMode = Config.LightModes[data.lightMode]
    if lightMode then
        SetVehicleSiren(vehicle, lightMode.sirenLights or false)
        SetVehicleHazardLights(vehicle, lightMode.hazards or false)
    end

    -- Hang: GTA natív szimt hangot ne duplázzuk, mert azt a motor kezeli
    -- Egyedi hang esetén: távolság alapú hangerő skaláz
end)

NUI panel nyitása / zarása

-- nxn-sirencontrol/client.lua:
RegisterCommand('sirencontrol', function()
    if not isInSirenVehicle then
        exports['nxn-notify']:send('Szimt panel', 'Csak szédülés járműben nyítható meg!', 'warn', 3000)
        return
    end
    isNUIOpen = not isNUIOpen
    SetNuiFocus(isNUIOpen, isNUIOpen)
    SendNUIMessage({
        action = 'toggle',
        open   = isNUIOpen,
        state  = {
            tone       = currentTone,
            lightMode  = currentLightMode,
            tones      = GetAllowedTones(),
            lightModes = Config.LightModes,
            model      = currentVehicleModel,
        }
    })
end, false)

RegisterNUICallback('setTone', function(data, cb)
    exports['nxn-sirencontrol']:setSirenTone(data.tone)
    cb({})
end)

RegisterNUICallback('setLightMode', function(data, cb)
    exports['nxn-sirencontrol']:setLightMode(data.mode)
    cb({})
end)

RegisterNUICallback('togglePanel', function(data, cb)
    isNUIOpen = false
    SetNuiFocus(false, false)
    SendNUIMessage({ action = 'toggle', open = false })
    cb({})
end)

Szerver: cache és eventek

-- nxn-sirencontrol/server.lua:
local sirenStates = {}  -- [src] = { tone, lightMode, vehicleNetId, model, activatedAt }

RegisterNetEvent('nxn-sirencontrol:server:updateState', function(data)
    local src = source
    local wasActive = sirenStates[src] ~= nil and sirenStates[src].tone ~= 'off'
    local isActive  = data.tone ~= 'off'

    local oldState = sirenStates[src]
    sirenStates[src] = {
        tone        = data.tone,
        lightMode   = data.lightMode,
        vehicleNetId = data.vehicleNetId,
        model       = data.model,
        activatedAt = wasActive and (oldState and oldState.activatedAt or os.time()) or os.time(),
    }

    -- Hálózati szinkron: más klienseknek broadcast
    if Config.NetworkSync then
        TriggerClientEvent('nxn-sirencontrol:client:remoteStateUpdate', -1, {
            srcNetId    = GetPlayerPed(src),
            vehicleNetId = data.vehicleNetId,
            tone        = data.tone,
            lightMode   = data.lightMode,
        })
    end

    -- Server eventek
    if not wasActive and isActive then
        TriggerEvent('nxn-sirencontrol:server:sirenActivated',
            src, data.tone, data.lightMode, data.vehicleNetId)

        -- Auto dispatch (ha config engedélyezi)
        if Config.AutoDispatch then
            AutoDispatchSiren(src, data)
        end

    elseif wasActive and not isActive then
        TriggerEvent('nxn-sirencontrol:server:sirenDeactivated', src, data.vehicleNetId)

    elseif wasActive and isActive and oldState and oldState.tone ~= data.tone then
        TriggerEvent('nxn-sirencontrol:server:toneChanged',
            src, oldState.tone, data.tone)

    elseif wasActive and isActive and oldState and oldState.lightMode ~= data.lightMode then
        TriggerEvent('nxn-sirencontrol:server:lightModeChanged',
            src, oldState.lightMode, data.lightMode)
    end
end)

RegisterNetEvent('nxn-sirencontrol:server:sirenOff', function()
    local src = source
    local old = sirenStates[src]
    if old then
        TriggerEvent('nxn-sirencontrol:server:sirenDeactivated', src,
            old.vehicleNetId)
    end
    sirenStates[src] = nil
end)

AddEventHandler('playerDropped', function()
    sirenStates[source] = nil
end)

📡 NUI Panel

A szimt panel egy kompakt, floatingmodális panel, amelyet a játékos a Z gombbal nyithat meg menet közben:

┌──────────────────────────────────────┐
│  🚨 SZIMT KEZELŐ                [X] │
│  Police Cruiser               │
├──────────────────────────────────────┤
│  TÓNUS                                 │
│  [ Wail ✓ ] [ Yelp ] [ Priority ]      │
│  [ Légkürt ] [ Manuális ] [ Ki ]        │
├──────────────────────────────────────┤
│  FÉNY MÓD                              │
│  [ Teljes ✓ ] [ Veszélyfény ]           │
│  [ Csendes ] [ Ki ]                     │
├──────────────────────────────────────┤
│  [🔊 MANUÁLIS KÜRT (lenyomva tartsd)] │
└──────────────────────────────────────┘

Panel elemek:

  • Jármű modell neve a fejlécben
  • Tónus gombok: csak az engedélyezett tónusok jelennek meg (jármű override alapján)
  • Aktiv tónus: kiemelve / aktiv stílus
  • Fény mód gombok: 4 mód
  • Manuális kürt gomb: mousedown → kürt on, mouseup → kürt off
  • Nexon dizájn sablon, Huge Icons
  • Nem backdrop-filter!

🔌 Integrációs példák más scriptekből

nxn-police (rendőrségi szimt állapot olvasás)

-- nxn-police/server.lua:
-- Rendőrségi üldözésnél ellenőrzi, hogy be van-e kapcsolva a szimt:
local function IsOfficerSirenActive(src)
    if GetResourceState('nxn-sirencontrol') ~= 'started' then return false end
    return exports['nxn-sirencontrol']:isSirenActive(src)
end

-- Például üldözés dispatch hívás indításakor:
if IsOfficerSirenActive(src) then
    exports['nxn-dispatch']:createCall({
        type    = 'pursuit',
        title   = 'Rendőrségi üldözés',
        coords  = GetEntityCoords(GetPlayerPed(src)),
        factions = { 'police', 'sheriff' },
        sourceSrc = src,
    })
end

nxn-dispatch (auto dispatch szimt aktiválásakor)

-- nxn-sirencontrol/server.lua:
local lastAutoDispatch = {}  -- [src] = os.time()

local function AutoDispatchSiren(src, data)
    if not Config.AutoDispatch then return end
    if GetResourceState('nxn-dispatch') ~= 'started' then return end

    local now = os.time()
    local last = lastAutoDispatch[src] or 0
    if (now - last) < Config.AutoDispatchCooldown then return end

    lastAutoDispatch[src] = now

    local ped    = GetPlayerPed(src)
    local coords = GetEntityCoords(ped)

    exports['nxn-dispatch']:createCall({
        type      = Config.AutoDispatchType,
        title     = 'Szimt aktiv – ' .. (data.model or 'jármű'),
        coords    = coords,
        sourceSrc = src,
        sourceName = GetPlayerName(src),
        autoClose = true,
    })
end

-- Szimt leállásakor szerver event
AddEventHandler('nxn-sirencontrol:server:sirenDeactivated', function(src, vehicleNetId)
    lastAutoDispatch[src] = nil  -- cooldown reset
end)

nxn-needs (környékbeli játékosok stressz növelés)

-- nxn-sirencontrol/client.lua:
-- Aktiv szimt mellett, Config.NearbyStressInterval ms-enként:
if Config.NearbyStressAmount > 0 and GetResourceState('nxn-needs') == 'started' then
    -- Mások stressz hatása: ez SZERVER oldalon kezelt,
    -- mert a kliens nem tudja, ki van a közelében
    -- Ezért a szerver oldalon a körülálló játékosoknak szól:
end

-- nxn-sirencontrol/server.lua:
AddEventHandler('nxn-sirencontrol:server:sirenActivated', function(src, tone, lightMode, vehicleNetId)
    if not Config.NearbyStressAmount or Config.NearbyStressAmount == 0 then return end
    if GetResourceState('nxn-needs') ~= 'started' then return end

    -- Periodikus stressz közelben lévőknek
    CreateThread(function()
        while sirenStates[src] and sirenStates[src].tone ~= 'off' do
            Wait(Config.NearbyStressInterval)
            local sirenPed = GetPlayerPed(src)
            local sirenCoords = GetEntityCoords(sirenPed)

            for _, playerSrc in ipairs(GetPlayers()) do
                local playerSrcNum = tonumber(playerSrc)
                if playerSrcNum ~= src then
                    local playerPed = GetPlayerPed(playerSrcNum)
                    local playerCoords = GetEntityCoords(playerPed)
                    if #(sirenCoords - playerCoords) <= Config.NearbyStressRadius then
                        exports['nxn-needs']:modifyNeed(playerSrcNum, 'stress',
                            Config.NearbyStressAmount)
                    end
                end
            end
        end
    end)
end)

nxn-hud (szimt badge)

-- nxn-sirencontrol/client.lua:
AddEventHandler('nxn-sirencontrol:client:stateChanged', function(data)
    if GetResourceState('nxn-hud') ~= 'started' then return end
    if data.tone ~= 'off' then
        exports['nxn-hud']:updateModuleData('siren', {
            tone      = data.tone,
            lightMode = data.lightMode,
            icon      = 'hgi-siren',
            color     = '#3498db',
        })
    else
        exports['nxn-hud']:updateModuleData('siren', nil)
    end
end)

nxn-duty (duty check aktiváláskor)

-- nxn-sirencontrol/client.lua:
local function CanActivateSiren()
    if not Config.RequireDuty then return true end
    if GetResourceState('nxn-duty') ~= 'started' then return true end

    for _, faction in ipairs(Config.DutyFactions) do
        if exports['nxn-duty']:isOnDuty(faction) then
            return true
        end
    end
    return false
end

✅ Implementációs checklist

Alap

  • fxmanifest.lua – dependencies: nxn-loading; opcionális: nxn-duty, nxn-dispatch, nxn-notify, nxn-needs, nxn-hud
  • config.lua – tónus sémák, fény módok, jármű override-ok, billentyűk, network beállítások
  • shared.luaNXN.SirenControl namespace, logger
  • client.lua – jármű detectálás, billentyűk, natív alkalmazás, NUI kezelés, exportok
  • server.lua – cache, szerver eventek, exportok, auto dispatch, needs integráció
  • html/ – Siren panel NUI

Kliens logika

  • 500ms-es thread: jármű detectálás (vezető szék, modell, szimt jármű check)
  • Jármű váltas: szimt state reset, NUI frissítés
  • Config.RequireDuty + nxn-duty:isOnDuty() check aktiválás előtt
  • E billentyű: szimt toggle (ki/be)
  • Q billentyű: tónus cycle (Config.ToneCycleOrder)
  • F billentyű: fény mód toggle
  • R billentyű: manuális kürt (IsControlPressed alapú, manuális módban)
  • Z billentyű: NUI panel toggle
  • ApplySirenTone(vehicle, toneId) belső függvény: GTA natív SetVehicleSiren, pattern, hazards
  • ApplyLightMode(vehicle, modeId) belső függvény
  • GetAllowedTones() belső függvény: jármű override alapján szűr
  • CanActivateSiren() belső függvény: duty check
  • Szerver szinkron: TriggerServerEvent state változáskor
  • Hálózati szinkron fogadása: nxn-sirencontrol:client:remoteStateUpdate – más játékosok szimtjének fény beállítása
  • Kliens exportok: isSirenActive(), getSirenMode(), getSirenTone(), getLightMode(), getCurrentVehicle(), isInSirenVehicle(), setSirenTone(id), setLightMode(id), toggleSiren()
  • nxn-hud:updateModuleData('siren', ...) hívás state változáskor
  • nxn-loading:updateModuleProgress('SirenControl', 100) betöltéskor
  • GetResourceState ellenőrzés minden opcionális export hívás előtt

Szerver logika

  • sirenStates cache tábla: [src] = { tone, lightMode, vehicleNetId, model, activatedAt }
  • nxn-sirencontrol:server:updateState net event handler
  • nxn-sirencontrol:server:sirenOff net event handler
  • playerDropped → cache cleanup
  • Hálózati szinkron broadcast: TriggerClientEvent('nxn-sirencontrol:client:remoteStateUpdate', -1, ...)
  • Server event triggerek: sirenActivated, sirenDeactivated, toneChanged, lightModeChanged
  • Auto dispatch: lastAutoDispatch cooldown cache + AutoDispatchSiren(src, data) függvény
  • nxn-needs periodikus stressz: szimt aktiváláskor thread indítás közelben lévőknek
  • Szerver exportok: isSirenActive(src), getSirenState(src), getSirenVehicle(src), getActiveSirenPlayers()
  • nxn-sirencontrol:client:forceOff admin export

NUI (html/)

  • Panel elem: jármű neve a fejlécben
  • Tónus gombok: csak engedélyezett tónusok (model override alapján NUI-ba küldve)
  • Aktiv gomb kiemelés
  • Fény mód gombok: 4 gomb
  • Manuális kürt gomb: mousedown/mouseup NUI callback
  • setTone, setLightMode, togglePanel, manualHornStart, manualHornStop NUI callbackek
  • Nexon dizájn sablon
  • Nem backdrop-filter!
  • Huge Icons: hgi-siren, hgi-wave, hgi-wave-up, hgi-alert-diamond, hgi-megaphone, hgi-sun-02, hgi-warning-triangle

Biztonság

  • Szerver oldali jármű közelség re-ellenőrzés (kliens ne küldhessen hamis state-et messze)
  • Model whitelist check: csak konfigolt vagy emergency class jármű kaphat szirmt (Config.VehicleOverrides + class 18)
  • Rate limit: max 1 state update / 500ms per játékos

Minőség

  • docs/index.html dokumentáció (nxn-example sablon alapján, Nexon dizájnnal)
  • fxmanifest.luadocs/index.html NEM kerül a files szekcióba
  • Debug mód: /sirendebug parancs – jelenlegi szimt state kiírás

🗓️ Szükséges módosítások más issue-kban

nxn-police (#158) – kiegészítés

Az nxn-police-nak az üldözés-logika során érdemes az nxn-sirencontrol isSirenActive(src) exportát használni:

-- nxn-police/server.lua – KIEGÉSZÍTÉS:
-- Üldözés dispatch automatikusan, ha a rendőr szirmt van:
AddEventHandler('nxn-sirencontrol:server:sirenActivated', function(src, tone, lightMode, vehicleNetId)
    if GetResourceState('nxn-duty') == 'started' then
        if not exports['nxn-duty']:isOnDuty(src, 'police')
            and not exports['nxn-duty']:isOnDuty(src, 'sheriff') then
            return  -- nem rendőr
        end
    end
    -- Rendőrségi szimt aktiváláskor: opcionális dispatch
    -- (csak ha Config.AutoDispatch = false, hogy ne duplikáljon)
end)

Checklist kiegészítés a #158 issue-ban:

  • nxn-sirencontrol:server:sirenActivated event figyelése opcionális üldözés dispatch-hoz
  • isSirenActive(src) export hívása üldözés validációnál

📎 Referenciák

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    newItems or codes have to be created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions