diff --git a/README.md b/README.md index 4fe9972..3b625d5 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,11 @@ You can refer to the type annotations, but here is an example: ```lua sirens = { -- make sure to keep the base sirens ABOVE the addon sirens - base = { ... }, + --base + { ... }, - addonSirenGroup1 = { + --Addon Group 1 (just a name for your reference) + { sirenModes = { --[[ This table has to be in the correct order, only 3 sirenModes (or steps (when pressing R) if you prefer) are supported diff --git a/client.lua b/client.lua index 7f19f00..08248e8 100644 --- a/client.lua +++ b/client.lua @@ -178,10 +178,12 @@ stateBagWrapper('horn', function(veh, value) local audioName = 'SIRENS_AIRHORN' -- Default sound local audioRef - for _, sirenConfig in pairs(config.sirens) do - if (not sirenConfig.models or sirenConfig.models[vehModel]) and sirenConfig.sirenModes.horn then - audioName = sirenConfig.sirenModes.horn?.audioName or audioName - audioRef = sirenConfig.sirenModes.horn?.audioRef or audioRef + for i = 1, #config.sirens do + local sirenConfig = config.sirens[i] + + if (not sirenConfig.models or sirenConfig.models[vehModel]) and sirenConfig.horn then + audioName = sirenConfig.horn?.audioName or audioName + audioRef = sirenConfig.horn?.audioRef or audioRef -- no break here, allows it to take the base config and if there's another valid config after, replace it. end end @@ -249,7 +251,8 @@ stateBagWrapper('sirenMode', function(veh, soundMode) audioName = 'PLAYER_FUCKED_SIREN' else local vehModel = GetEntityModel(veh) - for _, sirenConfig in pairs(config.sirens) do + for i = 1, #config.sirens do + local sirenConfig = config.sirens[i] if (not sirenConfig.models or sirenConfig.models[vehModel]) and sirenConfig.sirenModes[soundMode] then audioName = sirenConfig.sirenModes[soundMode]?.audioName or audioName audioRef = sirenConfig.sirenModes[soundMode]?.audioRef or audioRef diff --git a/config.lua b/config.lua index 6025ae0..27d6847 100644 --- a/config.lua +++ b/config.lua @@ -21,10 +21,11 @@ return { useEngineHealth = false, -- Determine wether to use engine health over body health for siren damage damageThreshold = 300, -- If the vehicle's health is below this value, the siren will be considered damaged - ---@type table + ---@type table --- Configure what siren sounds to use for a specific model and siren mode sirens = { - base = { + --base + { sirenModes = { { audioName = 'VEHICLES_HORNS_SIREN_1' }, { audioName = 'VEHICLES_HORNS_SIREN_2' }, @@ -36,7 +37,8 @@ return { } }, - fire = { + --fire + { sirenModes = { { audioName = 'RESIDENT_VEHICLES_SIREN_FIRETRUCK_QUICK_01' }, { audioName = 'RESIDENT_VEHICLES_SIREN_FIRETRUCK_WAIL_01' }, @@ -53,7 +55,8 @@ return { } }, - unmarked = { + --unmarked + { sirenModes = { { audioName = 'RESIDENT_VEHICLES_SIREN_WAIL_02' }, { audioName = 'RESIDENT_VEHICLES_SIREN_QUICK_02' } @@ -66,7 +69,8 @@ return { } }, - bikes = { + --bikes + { sirenModes = { { audioName = 'RESIDENT_VEHICLES_SIREN_WAIL_03' }, { audioName = 'RESIDENT_VEHICLES_SIREN_QUICK_03' }