From 31c47f738f8e8a16dead8fe2940c55232a9bbb18 Mon Sep 17 00:00:00 2001 From: Scully <51968381+Scullyy@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:39:39 -0800 Subject: [PATCH] Addon siren support --- Config.lua | 6 +++--- README.md | 18 +++++++++++++++++- client.lua | 27 ++++++++++++++++++++------- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Config.lua b/Config.lua index 970d3a5..8e944f7 100644 --- a/Config.lua +++ b/Config.lua @@ -1,6 +1,6 @@ return { Controls = { - PoliceLights = 'Q', + policeLights = 'Q', policeHorn = 'E', sirenToggle = 'LMENU', sirenCycle = 'R', @@ -8,6 +8,6 @@ return { addonHorns = { [`firetruk`] = 'VEHICLES_HORNS_FIRETRUCK_WARNING' }, - + addonSirens = {}, sirenShutOff = true -- Set to true if you want the siren to automatically shut off when the player exits the vehicle -} +} \ No newline at end of file diff --git a/README.md b/README.md index 8cba024..c72c929 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,23 @@ If you wish to change any keybinds you can do so in the client.lua - Place both resources into your server (make sure ox_lib is started before renewed sirensync) - and enjoy :) +## Addon Sirens + +If you have a server sided siren pack you can replace the sirens used in the `Config.lua`. You will need to add an entry for each model, for example: + +```lua +addonSirens = { + [`police5`] = { + ref = 'VEHAUD_LSPD_NEW_SOUNDSET', + horn = 'VEHAUD_LSPD_NEW_HORN', + a = 'VEHAUD_LSPD_NEW_SIREN_ADAM', + b = 'VEHAUD_LSPD_NEW_SIREN_BOY', + c = 'VEHAUD_LSPD_NEW_SIREN_CHARLES' + } +} +``` + ## Credits * [AvarianKnight](https://github.com/AvarianKnight) Original creator of PMA Sirensync. -* [BerkieBb](https://github.com/BerkieBb) Maintained PMA Sirensync. +* [BerkieBb](https://github.com/BerkieBb) Maintained PMA Sirensync. \ No newline at end of file diff --git a/client.lua b/client.lua index a4f30f5..35aa56a 100644 --- a/client.lua +++ b/client.lua @@ -1,4 +1,4 @@ -local Config = require 'Config' +local Config = lib.load('Config') -- soundId Tables -- local sirenVehicles = {} @@ -141,7 +141,7 @@ end) local policeLights = lib.addKeybind({ name = 'policeLights', description = 'Press this button to use your siren', - defaultKey = Config.Controls.PoliceLights, + defaultKey = Config.Controls.policeLights, onPressed = function() if not isVehAllowed() then return end @@ -179,9 +179,15 @@ stateBagWrapper('horn', function(veh, value) local soundId = GetSoundId() hornVehicles[veh] = soundId - local soundName = Config.addonHorns[GetEntityModel(veh)] or 'SIRENS_AIRHORN' + local modelName = GetEntityModel(veh) + local audioRef, soundName, addonSiren = 0, Config.addonHorns[modelName] or 'SIRENS_AIRHORN', Config.addonSirens[modelName] - PlaySoundFromEntity(soundId, soundName, veh, 0, false, 0) + if addonSiren then + audioRef = addonSiren.ref + soundName = addonSiren.horn + end + + PlaySoundFromEntity(soundId, soundName, veh, audioRef, false, 0) end) local policeHorn = lib.addKeybind({ @@ -235,13 +241,20 @@ stateBagWrapper('sirenMode', function(veh, soundMode) local soundId = GetSoundId() sirenVehicles[veh] = soundId + local audioRef, addonSiren = 0, Config.addonSirens[GetEntityModel(veh)] + local soundA, soundB, soundC = 'VEHICLES_HORNS_SIREN_1', 'VEHICLES_HORNS_SIREN_2', 'VEHICLES_HORNS_POLICE_WARNING' + + if addonSiren then + audioRef = addonSiren.ref + soundA, soundB, soundC = addonSiren.a, addonSiren.b, addonSiren.c + end if soundMode == 1 then - PlaySoundFromEntity(soundId, 'VEHICLES_HORNS_SIREN_1', veh, 0, false, 0) + PlaySoundFromEntity(soundId, soundA, veh, audioRef, false, 0) elseif soundMode == 2 then - PlaySoundFromEntity(soundId, 'VEHICLES_HORNS_SIREN_2', veh, 0, false, 0) + PlaySoundFromEntity(soundId, soundB, veh, audioRef, false, 0) elseif soundMode == 3 then - PlaySoundFromEntity(soundId, 'VEHICLES_HORNS_POLICE_WARNING', veh, 0, false, 0) + PlaySoundFromEntity(soundId, soundC, veh, audioRef, false, 0) end end)