Skip to content
View in the app

A better way to browse. Learn more.

LCPDFR.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C.E.S (Custom ELS Sirens) 1.7.0.3

(3 reviews)

1 Screenshot

This plugin is designed to run ALONGSIDE ELS, it does NOT replace it!

Requirements:

1. Grand Theft Auto V (Legit Copy)

2. RagePluginHook (Latest Version)

3. NAudio (Included)

4. ELS (Emergency Lighting System)

Installation:

1. Open the folder "Grand Theft Auto V" provided in this download.

2. Drag and drop all files and folders into your main GTA V installation directory.

(Where GTA5.exe is located).

Usage:

I suggest loading the Plugin on startup or else no sirens will work.

Drop your siren .WAV files in the "WAV" Folder.

Open the Menu (Default key: F10) and start customizing your sirens.

You can choose between a Global Profile (applies to all vehicles) and Vehicle Specific Profiles (overrides the Global Profile and only applies to a specific vehicle).

Showcase:

A note on the "Patch VCFs" Button:

This will turn off all sirens in the VCF .xml files inside your ELS -> pack_default Folder.

However C.E.S. will create a backup of your original VCFs.

After patching a game restart is required for the changes to take effect.

Although you can patch them yourself by searching for 'AllowUse="true"' under the <SOUNDS> category and setting 'true' to 'false'. Repeat for all.

How it should look:

<SOUNDS>

<MainHorn InterruptsSiren="true" AudioString="SIRENS_AIRHORN" />

<ManTone1 AllowUse="false" AudioString="VEHICLES_HORNS_SIREN_1" />

<ManTone2 AllowUse="false" AudioString="VEHICLES_HORNS_SIREN_2" />

<SrnTone1 AllowUse="false" AudioString="VEHICLES_HORNS_SIREN_1" />

<SrnTone2 AllowUse="false" AudioString="VEHICLES_HORNS_SIREN_2" />

<SrnTone3 AllowUse="false" AudioString="VEHICLES_HORNS_POLICE_WARNING" />

<SrnTone4 AllowUse="false" AudioString="VEHICLES_HORNS_AMBULANCE_WARNING" />

<AuxSiren AllowUse="false" AudioString="VEHICLES_HORNS_SIREN_1" />

<PanicMde AllowUse="false" AudioString="VEHICLES_HORNS_POLICE_WARNING" />

</SOUNDS>

Edited by TheMagentaButterfly

What's New in Version 1.7.0.3

Released

Fixed the Patch VCF Button not working.

Sirens now stop playing if the driver is dead

Bumped Assembly Version to v 1.7.0.3.

Known Bugs:

Plugin won't detect some Addon Vehicles as Emergency Vehicles (Do NOT report this bug!)


Short Description

C.E.S. allows you to have custom sirens for different ELS vehicles. With a In-Game editor it has never been easier to add Sirens

AI disclosure

The author has disclosed that AI tools were used in creating the following aspects of this file:

  • Mod and Mod Content (Moderate)

Ai helped me with the code where i couldn't find help online.

User Feedback

Recommended Comments

boomer2840

Members

where do you get the wave files from to put in the wave folder?

Coyote3D

Members

This is a mod I've been wanting for a while! I'm hoping for that addon bug to be fixed though.

0pheIia

Members

im glad to have this. you can already do this with the current els system but now its a lot easier and if you know how to do both you can get lots of different sirens. thank you.

TheMagentaButterfly

Members Author

9 hours ago, boomer2840 said:

where do you get the wave files from to put in the wave folder?

Download sirens from Lcpdfr.com and drop the files in the WAV folder.

0pheIia

Members

(edited)

can you add panic mode and aux siren and can you add a feature that choose whether we want the option interrupt the siren with the horn? I'd like to turn that off for some of these cars.

Edited by 0pheIia

TheMagentaButterfly

Members Author

9 minutes ago, 0pheIia said:

can you add panic mode and aux siren and can you add a feature that choose whether we want the option interrupt the siren with the horn? I'd like to turn that off for some of these cars.

Eventually. I'm currently also developing EmsPlus which takes a lot of time.

I made C.E.S. because I quickly get tired of the same sirens and replacing them with OpenIV isn't very user friendly.

I released this as a gift to this community.

0pheIia

Members

10 minutes ago, TheMagentaButterfly said:

Eventually. I'm currently also developing EmsPlus which takes a lot of time.

I made C.E.S. because I quickly get tired of the same sirens and replacing them with OpenIV isn't very user friendly.

I released this as a gift to this community.

i see glad too hear that. also idk if its just on my end but it appears that the volume for vehicles driving ai cars is unaffected by the menu. i have it set to 35 for all cars and its still very loud.

alex34244

Members

interesting so if i want to have differentt sirrens and choose what siren use for that patrol i can do that???

iSwayz

Members

Is there AI compatibility? Are the sirens played in the game or is it just a 2d audio being played?

0pheIia

Members

i also discovered that ai sirens can be heard even if they dont have their lights on when spawning them from policingredefined.

maurice216

Members

5 hours ago, alex34244 said:

interesting so if i want to have differentt sirrens and choose what siren use for that patrol i can do that???

22 hours ago, 0pheIia said:

im glad to have this. you can already do this with the current els system but now its a lot easier and if you know how to do both you can get lots of different sirens. thank you.

i cant get the plug in to work, i installed everything, but the sirens are still the default.

TheMagentaButterfly

Members Author

4 hours ago, maurice216 said:

i cant get the plug in to work, i installed everything, but the sirens are still the default.

Please read the description.

maurice216

Members

i read it, but i don't understand how to get the sirens to work now, the vcf's are like you showed in the description, however the sirens dont work when i try to ACTIVATE THEM, please help.

RougePOV

Members

(edited)

I love the mod man, only thing I wish is that there was controller support as it plays the normal audio with controller also I have an issue when AI get on scene they will turn there ELS lights off, fixed it by disabling auto siren shutoff inside your config but then the siren stays on but so do the ELS lights, is there also a way to disable to main games sirens completely so they do not play at all. if all these get patched 10/10 mod for sure

Edited by RougePOV

tee

Members

(edited)

I followed the tutorial, set it up i think and got my backup units to respond with the Custom siren but I cant get the custom siren to work on the vehicle I'm driving and yes I am driving the same vehicle the backup units have, and yes the sirens are continuing to play on the backup units after setting AutomaticAiSirenCutoff=False so i am kind of at a loss as I really want to use this mod

Edited by tee

TheMagentaButterfly

Members Author

1 hour ago, tee said:

I followed the tutorial, set it up i think and got my backup units to respond with the Custom siren but I cant get the custom siren to work on the vehicle I'm driving and yes I am driving the same vehicle the backup units have, and yes the sirens are continuing to play on the backup units after setting AutomaticAiSirenCutoff=False so i am kind of at a loss as I really want to use this mod

Setting the sirens cotuff to false will continue to play the sirens as when the drivers get out the siren won't be stopped, I recommend setting it to true.

As for your car, look in the console, if it says that your vehicle wasn't detected to have stage 3 lighting or not to be an emergency vehicle at all, it's a known bug

tee

Members

16 minutes ago, TheMagentaButterfly said:

Setting the sirens cotuff to false will continue to play the sirens as when the drivers get out the siren won't be stopped, I recommend setting it to true.

As for your car, look in the console, if it says that your vehicle wasn't detected to have stage 3 lighting or not to be an emergency vehicle at all, it's a known bug

Nevermind, I think I get it now I have to use the numeric row keys for the siren. I didn't understand that at first.

RougePOV

Members

3 hours ago, tee said:

Nevermind, I think I get it now I have to use the numeric row keys for the siren. I didn't understand that at first.

Hoping Magenta can add controller support at some point cause that would be really cool

tee

Members

5 hours ago, RougePOV said:

Hoping Magenta can add controller support at some point cause that would be really cool

yea because I am so used to using a controller I thought I missed a step in your vid.

tee

Members

While I am enjoying this mod, I do have a concern about it disabling the sirens on the non-els vehicles that I have active in game. Is there a way for it not to do that? or maybe update it for it not to affect the non els vehicles unless I want it to?

Sargegercy

Members

I have noticed that this mod will force Hybrid-ELS vehicles such as those found in the Osceola County pack into a somewhat broken "park" mode when I get out of a car that is currently code 3, any idea on how to fix this?

RougePOV

Members

10 hours ago, Sargegercy said:

I have noticed that this mod will force Hybrid-ELS vehicles such as those found in the Osceola County pack into a somewhat broken "park" mode when I get out of a car that is currently code 3, any idea on how to fix this?

I have also noticed this a bit, I personally do not know a fix. but hopefully it can get fixed. Maybe try customizing your ELS XML but not sure. prolly would be under <OutOfVeh Enabled="true" Pattern="SCAN" /> or something of that nature, prolly set it to false but yea mess around with it.

Sargegercy

Members

(edited)

13 hours ago, RougePOV said:

I have also noticed this a bit, I personally do not know a fix. but hopefully it can get fixed. Maybe try customizing your ELS XML but not sure. prolly would be under <OutOfVeh Enabled="true" Pattern="SCAN" /> or something of that nature, prolly set it to false but yea mess around with it.

13 hours ago, RougePOV said:

I did some chatgpt coding and fixed the block of code that breaks hybrid ELS patterns when a player isn't in the vehicle, this is in the sirenmanger subsection of the DLL, as far as I've tested it this works and fixes the problem



using System;using System.Collections.Generic;using System.IO;using System.Linq.Expressions;using System.Runtime.CompilerServices;using System.Windows.Forms;using System.Xml;using Microsoft.CSharp.RuntimeBinder;using Rage;using Rage.Native;
namespace CustomELSSirens{
    // Token: 0x0200000A RID: 10
    public static class SirenManager
    {
        // Token: 0x06000033 RID: 51 RVA: 0x00004158 File Offset: 0x00002358
        public static void ProcessLoop()
        {
            Ped character = Game.LocalPlayer.Character;
            bool flag = character == null || !character.IsAlive;
            if (flag)
            {
                SirenManager.KillAllSounds(true);
                SirenManager.KillAllAiSounds(true);
            }
            else
            {
                bool inVehicle = character.IsInAnyVehicle(false);
if (inVehicle){
    Vehicle vehicle = character.CurrentVehicle;

    bool switchedVehicle = SirenManager.currentVehicle != vehicle;

    if (switchedVehicle)
    {
        SirenManager.currentVehicle = vehicle;
        SirenManager.CurrentVehicleModel = SirenManager.GetVehicleModelName(vehicle);
        SirenManager.activeToneIndex = 0;
        SirenManager.isAutoScanActive = false;

        SirenManager.activeSiren.Stop(false);
       SirenManager.activeHorn?.Stop(false);SirenManager.activeManual?.Stop(false);SirenManager.activeSiren?.Stop(false);

        SirenManager.ParseVCF(SirenManager.CurrentVehicleModel);
        SirenManager._profileCache.Clear();
        SirenManager.CacheVehicleSirens();
    }}else{
    if (SirenManager.currentVehicle != null)
    {
        SirenManager.KillAllSounds(true);

        SirenManager.currentVehicle = null;
        SirenManager.CurrentVehicleModel = string.Empty;
        SirenManager.activeToneIndex = 0;
        SirenManager.isAutoScanActive = false;
    }}
                bool flag4 = SirenManager.currentVehicle != null && SirenManager.currentVehicle.IsValid() && SirenManager.currentVehicle.IsAlive;
                if (flag4)
                {
                    bool hasSiren = SirenManager.currentVehicle.HasSiren;
                    if (hasSiren)
                    {
                        if (SirenManager.<>o__26.<>p__0 == null)
                        {
                            SirenManager.<>o__26.<>p__0 = CallSite<Action<CallSite, object, Vehicle, bool>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "SET_VEHICLE_HAS_MUTED_SIRENS", new Type[]
                            {
                                typeof(bool)
                            }, typeof(SirenManager), new CSharpArgumentInfo[]
                            {
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                            }));
                        }
                        SirenManager.<>o__26.<>p__0.Target(SirenManager.<>o__26.<>p__0, NativeFunction.Natives, SirenManager.currentVehicle, true);
                        Game.DisableControlAction(0, 86, true);
                    }
                    bool flag5 = SirenManager.IsVehicleLightsOn(SirenManager.currentVehicle);
                    bool flag6 = SirenManager.currentVehicle != null && SirenManager.currentVehicle.IsValid() && SirenManager.currentVehicle.IsAlive;
                    if (flag6)
                    {
                        SirenManager.HandleInputs(SirenManager.currentVehicle, flag5);
                    }
                    else
                    {
                        bool isPlaying = SirenManager.activeHorn.IsPlaying;
                        if (isPlaying)
                        {
                            SirenManager.activeHorn.Stop(false);
                        }
                        bool isPlaying2 = SirenManager.activeManual.IsPlaying;
                        if (isPlaying2)
                        {
                            SirenManager.activeManual.Stop(false);
                        }
                        bool flag7 = PluginConfig.AutomaticAiSirenCutoff && SirenManager.currentVehicle.IsSirenOn;
                        if (flag7)
                        {
                            SirenManager.currentVehicle.IsSirenOn = false;
                            SirenManager.activeToneIndex = 0;
                            SirenManager.isAutoScanActive = false;
                            SirenManager.activeSiren.Stop(false);
                        }
                    }
                    bool flag8 = !flag5 && SirenManager.activeToneIndex != 0;
                    if (flag8)
                    {
                        SirenManager.activeToneIndex = 0;
                        SirenManager.isAutoScanActive = false;
                        SirenManager.activeSiren.Stop(false);
                    }
                }
                else
                {
                    SirenManager.KillAllSounds(false);
                }
                if (SirenManager.<>o__26.<>p__3 == null)
                {
                    SirenManager.<>o__26.<>p__3 = CallSite<Func<CallSite, object, bool>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(bool), typeof(SirenManager)));
                }
                Func<CallSite, object, bool> target = SirenManager.<>o__26.<>p__3.Target;
                CallSite <>p__ = SirenManager.<>o__26.<>p__3;
                bool flag9 = Game.IsPaused || Game.IsLoading;
                object arg2;
                if (!flag9)
                {
                    if (SirenManager.<>o__26.<>p__2 == null)
                    {
                        SirenManager.<>o__26.<>p__2 = CallSite<Func<CallSite, bool, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.BinaryOperationLogical, ExpressionType.Or, typeof(SirenManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                        }));
                    }
                    Func<CallSite, bool, object, object> target2 = SirenManager.<>o__26.<>p__2.Target;
                    CallSite <>p__2 = SirenManager.<>o__26.<>p__2;
                    bool arg = flag9;
                    if (SirenManager.<>o__26.<>p__1 == null)
                    {
                        SirenManager.<>o__26.<>p__1 = CallSite<Func<CallSite, object, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "IS_PAUSE_MENU_ACTIVE", new Type[]
                        {
                            typeof(bool)
                        }, typeof(SirenManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        }));
                    }
                    arg2 = target2(<>p__2, arg, SirenManager.<>o__26.<>p__1.Target(SirenManager.<>o__26.<>p__1, NativeFunction.Natives));
                }
                else
                {
                    arg2 = flag9;
                }
                bool flag10 = target(<>p__, arg2);
                bool flag11 = flag10;
                if (flag11)
                {
                    SirenManager.activeSiren.SetVolume(0f);
                    SirenManager.activeHorn.SetVolume(0f);
                    SirenManager.activeManual.SetVolume(0f);
                    foreach (AiSirenState aiSirenState in SirenManager.activeAiSirens.Values)
                    {
                        aiSirenState.Player.SetVolume(0f);
                    }
                }
                else
                {
                    bool flag12 = (MenuManager.MainMenu != null && MenuManager.MainMenu.Visible) || (MenuManager.SettingsMenu != null && MenuManager.SettingsMenu.Visible);
                    bool flag13 = flag12;
                    if (SirenManager.<>o__26.<>p__5 == null)
                    {
                        SirenManager.<>o__26.<>p__5 = CallSite<Func<CallSite, object, Vector3>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Vector3), typeof(SirenManager)));
                    }
                    Func<CallSite, object, Vector3> target3 = SirenManager.<>o__26.<>p__5.Target;
                    CallSite <>p__3 = SirenManager.<>o__26.<>p__5;
                    if (SirenManager.<>o__26.<>p__4 == null)
                    {
                        SirenManager.<>o__26.<>p__4 = CallSite<Func<CallSite, object, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "GET_GAMEPLAY_CAM_COORD", new Type[]
                        {
                            typeof(Vector3)
                        }, typeof(SirenManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        }));
                    }
                    Vector3 camPos = target3(<>p__3, SirenManager.<>o__26.<>p__4.Target(SirenManager.<>o__26.<>p__4, NativeFunction.Natives));
                    if (SirenManager.<>o__26.<>p__7 == null)
                    {
                        SirenManager.<>o__26.<>p__7 = CallSite<Func<CallSite, object, Vector3>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(Vector3), typeof(SirenManager)));
                    }
                    Func<CallSite, object, Vector3> target4 = SirenManager.<>o__26.<>p__7.Target;
                    CallSite <>p__4 = SirenManager.<>o__26.<>p__7;
                    if (SirenManager.<>o__26.<>p__6 == null)
                    {
                        SirenManager.<>o__26.<>p__6 = CallSite<Func<CallSite, object, int, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "GET_GAMEPLAY_CAM_ROT", new Type[]
                        {
                            typeof(Vector3)
                        }, typeof(SirenManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                        }));
                    }
                    Vector3 camRot = target4(<>p__4, SirenManager.<>o__26.<>p__6.Target(SirenManager.<>o__26.<>p__6, NativeFunction.Natives, 2));
                    bool flag14 = SirenManager.currentVehicle != null && SirenManager.currentVehicle.IsValid() && SirenManager.currentVehicle.IsAlive;
                    if (flag14)
                    {
                        bool forceMute = flag13 || SirenManager.activeHorn.IsPlaying || SirenManager.activeManual.IsPlaying;
                        SirenManager.activeSiren.Update3D(SirenManager.currentVehicle, camPos, camRot, forceMute);
                        SirenManager.activeHorn.Update3D(SirenManager.currentVehicle, camPos, camRot, flag13);
                        SirenManager.activeManual.Update3D(SirenManager.currentVehicle, camPos, camRot, flag13);
                    }
                    SirenManager.UpdateActiveAiSirens(camPos, camRot, flag13);
                }
                bool flag15 = Game.GameTime >= SirenManager.nextAiScanTime;
                if (flag15)
                {
                    SirenManager.nextAiScanTime = Game.GameTime + (uint)PluginConfig.AiScanInterval;
                    SirenManager.ScanForAiVehicles();
                }
            }
        }

        // Token: 0x06000034 RID: 52 RVA: 0x000047E4 File Offset: 0x000029E4
        public static void DropVolumes()
        {
            SirenManager.activeSiren.SetVolume(0f);
            SirenManager.activeHorn.SetVolume(0f);
            SirenManager.activeManual.SetVolume(0f);
        }

        // Token: 0x06000035 RID: 53 RVA: 0x00004818 File Offset: 0x00002A18
        public static void Shutdown()
        {
            SirenManager.activeSiren.Stop(true);
            SirenManager.activeHorn.Stop(true);
            SirenManager.activeManual.Stop(true);
            foreach (AiSirenState aiSirenState in SirenManager.activeAiSirens.Values)
            {
                aiSirenState.Player.Stop(true);
            }
            SirenManager.activeAiSirens.Clear();
            SirenManager.cachedSirens.Clear();
            SirenManager._profileCache.Clear();
            SirenManager._vehicleScratch.Clear();
            Game.Console.Print("[CustomSirens] Unloaded – all audio resources released.");
        }

        // Token: 0x06000036 RID: 54 RVA: 0x000048D8 File Offset: 0x00002AD8
        private static void KillAllSounds(bool dropInstantly = false)
        {
            bool isPlaying = SirenManager.activeSiren.IsPlaying;
            if (isPlaying)
            {
                SirenManager.activeSiren.Stop(dropInstantly);
            }
            bool isPlaying2 = SirenManager.activeHorn.IsPlaying;
            if (isPlaying2)
            {
                SirenManager.activeHorn.Stop(dropInstantly);
            }
            bool isPlaying3 = SirenManager.activeManual.IsPlaying;
            if (isPlaying3)
            {
                SirenManager.activeManual.Stop(dropInstantly);
            }
            SirenManager.activeToneIndex = 0;
            SirenManager.isAutoScanActive = false;
            SirenManager.currentVehicle = null;
        }

        // Token: 0x06000037 RID: 55 RVA: 0x00004948 File Offset: 0x00002B48
        private static void KillAllAiSounds(bool dropInstantly = false)
        {
            foreach (AiSirenState aiSirenState in SirenManager.activeAiSirens.Values)
            {
                aiSirenState.Player.Stop(dropInstantly);
            }
            SirenManager.activeAiSirens.Clear();
        }

        // Token: 0x06000038 RID: 56 RVA: 0x000049B4 File Offset: 0x00002BB4
        private static void ParseVCF(string modelName)
        {
            SirenManager.requiredSirenStage = 3;
            SirenManager.maxStage = 1;
            bool flag = !Directory.Exists("ELS");
            if (!flag)
            {
                string[] files = Directory.GetFiles("ELS", modelName + ".xml", SearchOption.AllDirectories);
                bool flag2 = files.Length == 0;
                if (!flag2)
                {
                    try
                    {
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.Load(files[0]);
                        XmlNode xmlNode = xmlDocument.SelectSingleNode("//MISC/DfltSirenLtsActivateAtLstg");
                        bool flag3 = xmlNode != null;
                        if (flag3)
                        {
                            int.TryParse(xmlNode.InnerText, out SirenManager.requiredSirenStage);
                        }
                        string[] array = new string[]
                        {
                            "PRML",
                            "WRNL",
                            "SECL"
                        };
                        foreach (string arg in array)
                        {
                            for (int j = 3; j >= 1; j--)
                            {
                                XmlNode xmlNode2 = xmlDocument.SelectSingleNode(string.Format("//{0}/PresetPatterns/Lstg{1}", arg, j));
                                bool flag4;
                                if (xmlNode2 == null)
                                {
                                    flag4 = (null != null);
                                }
                                else
                                {
                                    XmlAttributeCollection attributes = xmlNode2.Attributes;
                                    flag4 = (((attributes != null) ? attributes["Enabled"] : null) != null);
                                }
                                bool flag5 = flag4 && xmlNode2.Attributes["Enabled"].Value.Equals("true", StringComparison.OrdinalIgnoreCase);
                                if (flag5)
                                {
                                    bool flag6 = j > SirenManager.maxStage;
                                    if (flag6)
                                    {
                                        SirenManager.maxStage = j;
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }

        // Token: 0x06000039 RID: 57 RVA: 0x00004B50 File Offset: 0x00002D50
        private static string GetVehicleModelName(Vehicle veh)
        {
            bool flag = veh == null || !veh.IsValid();
            string result;
            if (flag)
            {
                result = "UNKNOWN";
            }
            else
            {
                string text = veh.Model.Name;
                bool flag2 = string.IsNullOrEmpty(text) || text.StartsWith("0x", StringComparison.OrdinalIgnoreCase);
                if (flag2)
                {
                    text = string.Format("0x{0:X8}", veh.Model.Hash);
                }
                result = text.ToUpper();
            }
            return result;
        }

        // Token: 0x0600003A RID: 58 RVA: 0x00004BD8 File Offset: 0x00002DD8
        private static void HandleInputs(Vehicle veh, bool isLightsOn)
        {
            SirenManager.CheckToneKey(PluginConfig.Snd_SrnTon1, ref SirenManager.was1, 1, isLightsOn);
            SirenManager.CheckToneKey(PluginConfig.Snd_SrnTon2, ref SirenManager.was2, 2, isLightsOn);
            SirenManager.CheckToneKey(PluginConfig.Snd_SrnTon3, ref SirenManager.was3, 3, isLightsOn);
            SirenManager.CheckToneKey(PluginConfig.Snd_SrnTon4, ref SirenManager.was4, 4, isLightsOn);
            bool flag = Game.IsKeyDownRightNow(PluginConfig.Sound_Manul);
            bool flag2 = flag && !SirenManager.wasManul;
            if (flag2)
            {
                string profileSiren = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, "Manual");
                bool flag3 = !string.IsNullOrEmpty(profileSiren) && profileSiren != "None" && File.Exists(profileSiren);
                int num = 1;
                bool flag4 = !flag3;
                if (flag4)
                {
                    bool flag5 = SirenManager.activeToneIndex == 0;
                    if (flag5)
                    {
                        num = 1;
                    }
                    else
                    {
                        bool flag6 = SirenManager.activeToneIndex == 1;
                        if (flag6)
                        {
                            num = 2;
                        }
                        else
                        {
                            bool flag7 = SirenManager.activeToneIndex == 2;
                            if (flag7)
                            {
                                num = 3;
                            }
                            else
                            {
                                bool flag8 = SirenManager.activeToneIndex == 3;
                                if (flag8)
                                {
                                    num = 4;
                                }
                                else
                                {
                                    bool flag9 = SirenManager.activeToneIndex == 4;
                                    if (flag9)
                                    {
                                        num = 1;
                                    }
                                }
                            }
                        }
                    }
                    bool flag10 = false;
                    for (int i = 0; i < 4; i++)
                    {
                        string profileSiren2 = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, string.Format("Tone{0}", num));
                        bool flag11 = !string.IsNullOrEmpty(profileSiren2) && profileSiren2 != "None" && File.Exists(profileSiren2);
                        if (flag11)
                        {
                            flag10 = true;
                            break;
                        }
                        num++;
                        bool flag12 = num > 4;
                        if (flag12)
                        {
                            num = 1;
                        }
                    }
                    bool flag13 = flag10;
                    if (flag13)
                    {
                        profileSiren = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, string.Format("Tone{0}", num));
                    }
                }
                bool flag14 = !string.IsNullOrEmpty(profileSiren) && profileSiren != "None" && File.Exists(profileSiren);
                if (flag14)
                {
                    CachedSound cachedSound = SirenManager.GetCachedSound(profileSiren);
                    bool flag15 = cachedSound != null;
                    if (flag15)
                    {
                        SirenManager.activeManual.Play(cachedSound, true, flag3 ? PluginConfig.ManualVol : SirenManager.GetPerSirenVolume(string.Format("Tone{0}Vol", num)));
                    }
                }
            }
            else
            {
                bool flag16 = !flag && SirenManager.wasManul;
                if (flag16)
                {
                    SirenManager.activeManual.Stop(false);
                }
            }
            SirenManager.wasManul = flag;
            bool flag17 = Game.IsKeyDownRightNow(PluginConfig.Snd_SrnScan);
            bool flag18 = flag17 && !SirenManager.wasScan;
            if (flag18)
            {
                if (isLightsOn)
                {
                    bool flag19 = SirenManager.isAutoScanActive;
                    if (flag19)
                    {
                        SirenManager.isAutoScanActive = false;
                        SirenManager.activeToneIndex = 0;
                        SirenManager.activeSiren.Stop(false);
                    }
                    else
                    {
                        SirenManager.isAutoScanActive = true;
                        SirenManager.activeToneIndex = 1;
                        string profileSiren3 = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, "Tone1");
                        bool flag20 = string.IsNullOrEmpty(profileSiren3) || profileSiren3 == "None" || !File.Exists(profileSiren3);
                        if (flag20)
                        {
                            SirenManager.AdvanceToNextValidTone(ref SirenManager.activeToneIndex);
                        }
                        SirenManager.PlayCurrentTone();
                        SirenManager.nextScanChangeTime = Game.GameTime + 6000U;
                    }
                }
                else
                {
                    Game.Console.Print("[CustomSirens] Vehicle emergency lights must be active to trigger custom sirens.");
                }
            }
            SirenManager.wasScan = flag17;
            bool flag21 = SirenManager.isAutoScanActive && SirenManager.activeToneIndex != 0;
            if (flag21)
            {
                bool flag22 = Game.GameTime > SirenManager.nextScanChangeTime;
                if (flag22)
                {
                    SirenManager.AdvanceToNextValidTone(ref SirenManager.activeToneIndex);
                    SirenManager.PlayCurrentTone();
                    SirenManager.nextScanChangeTime = Game.GameTime + 6000U;
                }
            }
            bool flag23 = Game.IsKeyDownRightNow(PluginConfig.Snd_SrnTonX);
            SirenManager.wasTonX = flag23;
            bool flag24 = Game.IsKeyDownRightNow(PluginConfig.Snd_SrnPnic);
            SirenManager.wasPnic = flag24;
            if (SirenManager.<>o__33.<>p__1 == null)
            {
                SirenManager.<>o__33.<>p__1 = CallSite<Func<CallSite, object, bool>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(bool), typeof(SirenManager)));
            }
            Func<CallSite, object, bool> target = SirenManager.<>o__33.<>p__1.Target;
            CallSite <>p__ = SirenManager.<>o__33.<>p__1;
            if (SirenManager.<>o__33.<>p__0 == null)
            {
                SirenManager.<>o__33.<>p__0 = CallSite<Func<CallSite, object, int, int, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "IS_DISABLED_CONTROL_PRESSED", new Type[]
                {
                    typeof(bool)
                }, typeof(SirenManager), new CSharpArgumentInfo[]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null),
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                }));
            }
            bool flag25 = target(<>p__, SirenManager.<>o__33.<>p__0.Target(SirenManager.<>o__33.<>p__0, NativeFunction.Natives, 0, 86));
            bool flag26 = flag25 && !SirenManager.wasHorn;
            if (flag26)
            {
                string profileSiren4 = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, "Horn");
                bool flag27 = !string.IsNullOrEmpty(profileSiren4) && profileSiren4 != "None" && File.Exists(profileSiren4);
                if (flag27)
                {
                    CachedSound cachedSound2 = SirenManager.GetCachedSound(profileSiren4);
                    bool flag28 = cachedSound2 != null;
                    if (flag28)
                    {
                        SirenManager.activeHorn.Play(cachedSound2, true, SirenManager.GetPerSirenVolume("HornVol"));
                    }
                }
            }
            else
            {
                bool flag29 = !flag25 && SirenManager.wasHorn;
                if (flag29)
                {
                    SirenManager.activeHorn.Stop(false);
                }
            }
            SirenManager.wasHorn = flag25;
        }

        // Token: 0x0600003B RID: 59 RVA: 0x000050D8 File Offset: 0x000032D8
        private static void AdvanceToNextValidTone(ref int toneIndex)
        {
            int num = (toneIndex == 0) ? 1 : toneIndex;
            int num2 = num;
            for (int i = 0; i < 4; i++)
            {
                num2++;
                bool flag = num2 > 4;
                if (flag)
                {
                    num2 = 1;
                }
                string profileSiren = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, string.Format("Tone{0}", num2));
                bool flag2 = !string.IsNullOrEmpty(profileSiren) && profileSiren != "None" && File.Exists(profileSiren);
                if (flag2)
                {
                    toneIndex = num2;
                    break;
                }
            }
        }

        // Token: 0x0600003C RID: 60 RVA: 0x0000515C File Offset: 0x0000335C
        private static void PlayCurrentTone()
        {
            string profileSiren = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, string.Format("Tone{0}", SirenManager.activeToneIndex));
            CachedSound cachedSound = SirenManager.GetCachedSound(profileSiren);
            bool flag = cachedSound != null;
            if (flag)
            {
                SirenManager.activeSiren.Play(cachedSound, true, SirenManager.GetPerSirenVolume(string.Format("Tone{0}Vol", SirenManager.activeToneIndex)));
            }
        }

        // Token: 0x0600003D RID: 61 RVA: 0x000051C0 File Offset: 0x000033C0
        private static void CheckToneKey(Keys key, ref bool wasKey, int toneIndex, bool isLightsOn)
        {
            bool flag = Game.IsKeyDownRightNow(key);
            bool flag2 = flag && !wasKey;
            if (flag2)
            {
                bool flag3 = !isLightsOn;
                if (flag3)
                {
                    Game.Console.Print("[CustomSirens] Vehicle emergency lights must be active to trigger custom sirens.");
                }
                else
                {
                    string profileSiren = SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, string.Format("Tone{0}", toneIndex));
                    bool flag4 = string.IsNullOrEmpty(profileSiren) || profileSiren == "None" || !File.Exists(profileSiren);
                    if (flag4)
                    {
                        wasKey = flag;
                        return;
                    }
                    bool flag5 = SirenManager.activeToneIndex == toneIndex;
                    if (flag5)
                    {
                        bool flag6 = SirenManager.isAutoScanActive;
                        if (flag6)
                        {
                            SirenManager.isAutoScanActive = false;
                        }
                        else
                        {
                            SirenManager.activeToneIndex = 0;
                            SirenManager.activeSiren.Stop(false);
                        }
                    }
                    else
                    {
                        SirenManager.isAutoScanActive = false;
                        SirenManager.activeToneIndex = toneIndex;
                        CachedSound cachedSound = SirenManager.GetCachedSound(profileSiren);
                        bool flag7 = cachedSound != null;
                        if (flag7)
                        {
                            SirenManager.activeSiren.Play(cachedSound, true, SirenManager.GetPerSirenVolume(string.Format("Tone{0}Vol", toneIndex)));
                        }
                    }
                }
            }
            wasKey = flag;
        }

        // Token: 0x0600003E RID: 62 RVA: 0x000052D8 File Offset: 0x000034D8
        private static float GetPerSirenVolume(string configKey)
        {
            float result;
            if (!(configKey == "Tone1Vol"))
            {
                if (!(configKey == "Tone2Vol"))
                {
                    if (!(configKey == "Tone3Vol"))
                    {
                        if (!(configKey == "Tone4Vol"))
                        {
                            if (!(configKey == "HornVol"))
                            {
                                if (!(configKey == "ManualVol"))
                                {
                                    result = 1f;
                                }
                                else
                                {
                                    result = PluginConfig.ManualVol;
                                }
                            }
                            else
                            {
                                result = PluginConfig.HornVol;
                            }
                        }
                        else
                        {
                            result = PluginConfig.Tone4Vol;
                        }
                    }
                    else
                    {
                        result = PluginConfig.Tone3Vol;
                    }
                }
                else
                {
                    result = PluginConfig.Tone2Vol;
                }
            }
            else
            {
                result = PluginConfig.Tone1Vol;
            }
            return result;
        }

        // Token: 0x0600003F RID: 63 RVA: 0x00005374 File Offset: 0x00003574
        private static string GetProfileSiren(string modelName, string key)
        {
            bool flag = string.IsNullOrEmpty(modelName);
            string result;
            if (flag)
            {
                result = "None";
            }
            else
            {
                string key2 = modelName + "|" + key;
                string text;
                bool flag2 = SirenManager._profileCache.TryGetValue(key2, out text);
                if (flag2)
                {
                    result = text;
                }
                else
                {
                    string text2 = PluginConfig.ProfilesFolder + modelName + ".ini";
                    bool flag3 = File.Exists(text2);
                    string text4;
                    if (flag3)
                    {
                        InitializationFile initializationFile = new InitializationFile(text2);
                        string text3 = initializationFile.ReadString("Sirens", key, "None");
                        text4 = ((text3 != "None" && File.Exists(PluginConfig.WavFolder + text3)) ? (PluginConfig.WavFolder + text3) : "None");
                    }
                    else
                    {
                        InitializationFile initializationFile2 = new InitializationFile(PluginConfig.ProfilesFolder + "Global.ini");
                        string text5 = initializationFile2.ReadString("Sirens", key, "None");
                        text4 = ((text5 != "None" && File.Exists(PluginConfig.WavFolder + text5)) ? (PluginConfig.WavFolder + text5) : "None");
                    }
                    SirenManager._profileCache[key2] = text4;
                    result = text4;
                }
            }
            return result;
        }

        // Token: 0x06000040 RID: 64 RVA: 0x000054AC File Offset: 0x000036AC
        public static CachedSound GetCachedSound(string path)
        {
            bool flag = string.IsNullOrEmpty(path) || path == "None" || !File.Exists(path);
            CachedSound result;
            if (flag)
            {
                result = null;
            }
            else
            {
                CachedSound cachedSound;
                bool flag2 = !SirenManager.cachedSirens.TryGetValue(path, out cachedSound);
                if (flag2)
                {
                    try
                    {
                        cachedSound = new CachedSound(path);
                        SirenManager.cachedSirens[path] = cachedSound;
                    }
                    catch (Exception ex)
                    {
                        Game.Console.Print("[CustomSirens] RAM Caching Failed for " + path + ": " + ex.Message);
                        return null;
                    }
                }
                result = cachedSound;
            }
            return result;
        }

        // Token: 0x06000041 RID: 65 RVA: 0x00005550 File Offset: 0x00003750
        public static void ClearProfileCache()
        {
            SirenManager._profileCache.Clear();
        }

        // Token: 0x06000042 RID: 66 RVA: 0x00005560 File Offset: 0x00003760
        public static void CacheVehicleSirens()
        {
            SirenManager.vehicleProfileExists = File.Exists(PluginConfig.ProfilesFolder + SirenManager.CurrentVehicleModel + ".ini");
            foreach (string key in new string[]
            {
                "Tone1",
                "Tone2",
                "Tone3",
                "Tone4",
                "Horn",
                "Manual"
            })
            {
                SirenManager.GetCachedSound(SirenManager.GetProfileSiren(SirenManager.CurrentVehicleModel, key));
            }
        }

        // Token: 0x06000043 RID: 67 RVA: 0x000055E8 File Offset: 0x000037E8
        private static bool IsVehicleLightsOn(Vehicle veh)
        {
            bool flag = veh == null || !veh.IsValid();
            bool result;
            if (flag)
            {
                result = false;
            }
            else
            {
                if (SirenManager.<>o__42.<>p__1 == null)
                {
                    SirenManager.<>o__42.<>p__1 = CallSite<Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(SirenManager), new CSharpArgumentInfo[]
                    {
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                    }));
                }
                Func<CallSite, object, bool> target = SirenManager.<>o__42.<>p__1.Target;
                CallSite <>p__ = SirenManager.<>o__42.<>p__1;
                if (SirenManager.<>o__42.<>p__0 == null)
                {
                    SirenManager.<>o__42.<>p__0 = CallSite<Func<CallSite, object, Vehicle, string, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "DECOR_EXIST_ON", new Type[]
                    {
                        typeof(bool)
                    }, typeof(SirenManager), new CSharpArgumentInfo[]
                    {
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                    }));
                }
                bool flag2 = target(<>p__, SirenManager.<>o__42.<>p__0.Target(SirenManager.<>o__42.<>p__0, NativeFunction.Natives, veh, "ELS_lightstage"));
                if (flag2)
                {
                    if (SirenManager.<>o__42.<>p__3 == null)
                    {
                        SirenManager.<>o__42.<>p__3 = CallSite<Func<CallSite, object, int>>.Create(Binder.Convert(CSharpBinderFlags.None, typeof(int), typeof(SirenManager)));
                    }
                    Func<CallSite, object, int> target2 = SirenManager.<>o__42.<>p__3.Target;
                    CallSite <>p__2 = SirenManager.<>o__42.<>p__3;
                    if (SirenManager.<>o__42.<>p__2 == null)
                    {
                        SirenManager.<>o__42.<>p__2 = CallSite<Func<CallSite, object, Vehicle, string, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.None, "DECOR_GET_INT", new Type[]
                        {
                            typeof(int)
                        }, typeof(SirenManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                        }));
                    }
                    int num = target2(<>p__2, SirenManager.<>o__42.<>p__2.Target(SirenManager.<>o__42.<>p__2, NativeFunction.Natives, veh, "ELS_lightstage"));
                    result = (num >= SirenManager.requiredSirenStage);
                }
                else
                {
                    result = veh.IsSirenOn;
                }
            }
            return result;
        }

        // Token: 0x06000044 RID: 68 RVA: 0x000057C0 File Offset: 0x000039C0
        private static void ScanForAiVehicles()
        {
            bool flag = Game.LocalPlayer.Character == null;
            if (!flag)
            {
                Vector3 position = Game.LocalPlayer.Character.Position;
                SirenManager._vehicleScratch.Clear();
                foreach (KeyValuePair<Vehicle, AiSirenState> keyValuePair in SirenManager.activeAiSirens)
                {
                    bool flag2 = !keyValuePair.Key.IsValid() || !keyValuePair.Key.IsAlive || Vector3.Distance(position, keyValuePair.Key.Position) > PluginConfig.MaxDistance;
                    if (flag2)
                    {
                        SirenManager._vehicleScratch.Add(keyValuePair.Key);
                    }
                }
                foreach (Vehicle key in SirenManager._vehicleScratch)
                {
                    AiSirenState aiSirenState;
                    bool flag3 = SirenManager.activeAiSirens.TryGetValue(key, out aiSirenState);
                    if (flag3)
                    {
                        aiSirenState.Player.Stop(false);
                    }
                    SirenManager.activeAiSirens.Remove(key);
                }
                Vehicle[] allVehicles = World.GetAllVehicles();
                foreach (Vehicle vehicle in allVehicles)
                {
                    bool flag4 = SirenManager.activeAiSirens.Count >= PluginConfig.MaxAiUnits;
                    if (flag4)
                    {
                        break;
                    }
                    bool flag5 = !vehicle.IsValid() || !vehicle.IsAlive || vehicle == SirenManager.currentVehicle;
                    if (!flag5)
                    {
                        bool flag6 = SirenManager.activeAiSirens.ContainsKey(vehicle);
                        if (!flag6)
                        {
                            string vehicleModelName = SirenManager.GetVehicleModelName(vehicle);
                            bool flag7 = vehicle.HasSiren || vehicle.Class == 18 || File.Exists("ELS\\" + vehicleModelName + ".xml");
                            bool flag8 = !flag7;
                            if (!flag8)
                            {
                                bool flag9 = Vector3.Distance(position, vehicle.Position) > PluginConfig.MaxDistance;
                                if (!flag9)
                                {
                                    bool flag10 = vehicle.Driver == null || !vehicle.Driver.IsValid();
                                    bool flag11 = flag10 && PluginConfig.AutomaticAiSirenCutoff;
                                    if (flag11)
                                    {
                                        bool isSirenOn = vehicle.IsSirenOn;
                                        if (isSirenOn)
                                        {
                                            vehicle.IsSirenOn = false;
                                        }
                                    }
                                    else
                                    {
                                        bool flag12 = vehicle.IsSirenOn || SirenManager.IsVehicleLightsOn(vehicle);
                                        bool flag13 = flag12;
                                        if (flag13)
                                        {
                                            string profileSiren = SirenManager.GetProfileSiren(vehicleModelName, "Tone1");
                                            CachedSound cachedSound = SirenManager.GetCachedSound(profileSiren);
                                            bool flag14 = cachedSound != null;
                                            if (flag14)
                                            {
                                                if (SirenManager.<>o__43.<>p__0 == null)
                                                {
                                                    SirenManager.<>o__43.<>p__0 = CallSite<Action<CallSite, object, Vehicle, bool>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "SET_VEHICLE_HAS_MUTED_SIRENS", new Type[]
                                                    {
                                                        typeof(bool)
                                                    }, typeof(SirenManager), new CSharpArgumentInfo[]
                                                    {
                                                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                                        CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                                                    }));
                                                }
                                                SirenManager.<>o__43.<>p__0.Target(SirenManager.<>o__43.<>p__0, NativeFunction.Natives, vehicle, true);
                                                SirenPlayer sirenPlayer = new SirenPlayer();
                                                sirenPlayer.Play(cachedSound, true, PluginConfig.Tone1Vol);
                                                AiSirenState value = new AiSirenState
                                                {
                                                    Player = sirenPlayer,
                                                    CurrentToneIndex = 1,
                                                    NextToneChangeTime = Game.GameTime + (uint)SirenManager.rnd.Next(4000, 8000)
                                                };
                                                SirenManager.activeAiSirens[vehicle] = value;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        // Token: 0x06000045 RID: 69 RVA: 0x00005B74 File Offset: 0x00003D74
        private static void UpdateActiveAiSirens(Vector3 camPos, Vector3 camRot, bool forceMuteAll = false)
        {
            bool flag = SirenManager.activeAiSirens.Count == 0;
            if (!flag)
            {
                SirenManager._vehicleScratch.Clear();
                foreach (KeyValuePair<Vehicle, AiSirenState> keyValuePair in SirenManager.activeAiSirens)
                {
                    Vehicle key = keyValuePair.Key;
                    AiSirenState value = keyValuePair.Value;
                    SirenPlayer player = value.Player;
                    bool flag2 = !key.IsValid() || !key.IsAlive || key == SirenManager.currentVehicle;
                    if (flag2)
                    {
                        player.Stop(false);
                        SirenManager._vehicleScratch.Add(key);
                    }
                    else
                    {
                        bool flag3 = key.Driver == null || !key.Driver.IsValid();
                        bool flag4 = (!flag3 && !key.Driver.IsAlive) || (flag3 && PluginConfig.AutomaticAiSirenCutoff);
                        if (flag4)
                        {
                            bool isSirenOn = key.IsSirenOn;
                            if (isSirenOn)
                            {
                                key.IsSirenOn = false;
                            }
                            player.Stop(false);
                            SirenManager._vehicleScratch.Add(key);
                        }
                        else
                        {
                            bool flag5 = key.IsSirenOn || SirenManager.IsVehicleLightsOn(key);
                            bool flag6 = !flag5;
                            if (flag6)
                            {
                                bool isPlaying = player.IsPlaying;
                                if (isPlaying)
                                {
                                    player.Stop(false);
                                }
                            }
                            else
                            {
                                string vehicleModelName = SirenManager.GetVehicleModelName(key);
                                bool flag7 = !player.IsPlaying;
                                if (flag7)
                                {
                                    string profileSiren = SirenManager.GetProfileSiren(vehicleModelName, string.Format("Tone{0}", value.CurrentToneIndex));
                                    bool flag8 = string.IsNullOrEmpty(profileSiren) || profileSiren == "None" || !File.Exists(profileSiren);
                                    if (flag8)
                                    {
                                        value.CurrentToneIndex = 1;
                                        profileSiren = SirenManager.GetProfileSiren(vehicleModelName, "Tone1");
                                    }
                                    CachedSound cachedSound = SirenManager.GetCachedSound(profileSiren);
                                    bool flag9 = cachedSound != null;
                                    if (flag9)
                                    {
                                        if (SirenManager.<>o__44.<>p__0 == null)
                                        {
                                            SirenManager.<>o__44.<>p__0 = CallSite<Action<CallSite, object, Vehicle, bool>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "SET_VEHICLE_HAS_MUTED_SIRENS", new Type[]
                                            {
                                                typeof(bool)
                                            }, typeof(SirenManager), new CSharpArgumentInfo[]
                                            {
                                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null),
                                                CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                                            }));
                                        }
                                        SirenManager.<>o__44.<>p__0.Target(SirenManager.<>o__44.<>p__0, NativeFunction.Natives, key, true);
                                        player.Play(cachedSound, true, SirenManager.GetPerSirenVolume(string.Format("Tone{0}Vol", value.CurrentToneIndex)));
                                        value.NextToneChangeTime = Game.GameTime + (uint)SirenManager.rnd.Next(4000, 8000);
                                    }
                                }
                                else
                                {
                                    bool flag10 = Game.GameTime > value.NextToneChangeTime && !forceMuteAll;
                                    if (flag10)
                                    {
                                        int num = value.CurrentToneIndex;
                                        bool flag11 = false;
                                        for (int i = 0; i < 4; i++)
                                        {
                                            num++;
                                            bool flag12 = num > 4;
                                            if (flag12)
                                            {
                                                num = 1;
                                            }
                                            string profileSiren2 = SirenManager.GetProfileSiren(vehicleModelName, string.Format("Tone{0}", num));
                                            bool flag13 = !string.IsNullOrEmpty(profileSiren2) && profileSiren2 != "None" && File.Exists(profileSiren2);
                                            if (flag13)
                                            {
                                                flag11 = true;
                                                break;
                                            }
                                        }
                                        bool flag14 = flag11 && num != value.CurrentToneIndex;
                                        if (flag14)
                                        {
                                            string profileSiren3 = SirenManager.GetProfileSiren(vehicleModelName, string.Format("Tone{0}", num));
                                            CachedSound cachedSound2 = SirenManager.GetCachedSound(profileSiren3);
                                            bool flag15 = cachedSound2 != null;
                                            if (flag15)
                                            {
                                                player.Play(cachedSound2, true, SirenManager.GetPerSirenVolume(string.Format("Tone{0}Vol", num)));
                                                value.CurrentToneIndex = num;
                                            }
                                        }
                                        value.NextToneChangeTime = Game.GameTime + (uint)SirenManager.rnd.Next(4000, 8000);
                                    }
                                }
                                player.Update3D(key, camPos, camRot, forceMuteAll);
                            }
                        }
                    }
                }
                foreach (Vehicle key2 in SirenManager._vehicleScratch)
                {
                    SirenManager.activeAiSirens.Remove(key2);
                }
            }
        }

        // Token: 0x06000046 RID: 70 RVA: 0x00006010 File Offset: 0x00004210
        // Note: this type is marked as 'beforefieldinit'.
        static SirenManager()
        {
        }

        // Token: 0x04000054 RID: 84
        public static Dictionary<string, CachedSound> cachedSirens = new Dictionary<string, CachedSound>(StringComparer.OrdinalIgnoreCase);

        // Token: 0x04000055 RID: 85
        private static readonly Dictionary<string, string> _profileCache = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

        // Token: 0x04000056 RID: 86
        private static readonly List<Vehicle> _vehicleScratch = new List<Vehicle>();

        // Token: 0x04000057 RID: 87
        private static readonly SirenPlayer activeSiren = new SirenPlayer();

        // Token: 0x04000058 RID: 88
        private static readonly SirenPlayer activeHorn = new SirenPlayer();

        // Token: 0x04000059 RID: 89
        private static readonly SirenPlayer activeManual = new SirenPlayer();

        // Token: 0x0400005A RID: 90
        private static readonly Dictionary<Vehicle, AiSirenState> activeAiSirens = new Dictionary<Vehicle, AiSirenState>();

        // Token: 0x0400005B RID: 91
        private static Vehicle currentVehicle = null;

        // Token: 0x0400005C RID: 92
        public static string CurrentVehicleModel = string.Empty;

        // Token: 0x0400005D RID: 93
        private static int maxStage = 3;

        // Token: 0x0400005E RID: 94
        private static int requiredSirenStage = 3;

        // Token: 0x0400005F RID: 95
        private static bool vehicleProfileExists = false;

        // Token: 0x04000060 RID: 96
        private static int activeToneIndex = 0;

        // Token: 0x04000061 RID: 97
        private static bool isAutoScanActive = false;

        // Token: 0x04000062 RID: 98
        private static uint nextScanChangeTime = 0U;

        // Token: 0x04000063 RID: 99
        private static bool was1;

        // Token: 0x04000064 RID: 100
        private static bool was2;

        // Token: 0x04000065 RID: 101
        private static bool was3;

        // Token: 0x04000066 RID: 102
        private static bool was4;

        // Token: 0x04000067 RID: 103
        private static bool wasHorn;

        // Token: 0x04000068 RID: 104
        private static bool wasManul;

        // Token: 0x04000069 RID: 105
        private static bool wasScan;

        // Token: 0x0400006A RID: 106
        private static bool wasTonX;

        // Token: 0x0400006B RID: 107
        private static bool wasPnic;

        // Token: 0x0400006C RID: 108
        private static uint nextAiScanTime = 0U;

        // Token: 0x0400006D RID: 109
        private static readonly Random rnd = new Random();
    }}

Edited by Sargegercy

darrragg

Members

when i press 1 it uses the siren in game and the added one using this plugin

Create an account or sign in to comment

Latest Mods

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.