Exemple #1
0
        public Siren(Vehicle vehicle, Vcfroot vcfroot, [Optional] IDictionary <string, object> data, IPatterns patt)
        {
            _vcf               = vcfroot;
            _vehicle           = vehicle;
            _patternController = patt;
            Function.Call(Hash.DISABLE_VEHICLE_IMPACT_EXPLOSION_ACTIVATION, _vehicle, true);
            Utils.DebugWriteLine(_vehicle.DisplayName);

            _tones = new Tones
            {
                horn       = new Tone(vcfroot.SOUNDS.MainHorn.AudioString, _vehicle, ToneType.Horn, true),
                tone1      = new Tone(vcfroot.SOUNDS.SrnTone1.AudioString, _vehicle, ToneType.SrnTon1, vcfroot.SOUNDS.SrnTone1.AllowUse),
                tone2      = new Tone(vcfroot.SOUNDS.SrnTone2.AudioString, _vehicle, ToneType.SrnTon2, vcfroot.SOUNDS.SrnTone2.AllowUse),
                tone3      = new Tone(vcfroot.SOUNDS.SrnTone3.AudioString, _vehicle, ToneType.SrnTon3, vcfroot.SOUNDS.SrnTone3.AllowUse),
                tone4      = new Tone(vcfroot.SOUNDS.SrnTone4.AudioString, _vehicle, ToneType.SrnTon4, vcfroot.SOUNDS.SrnTone4.AllowUse),
                panicAlarm = new Tone(vcfroot.SOUNDS.PanicMde.AudioString, _vehicle, ToneType.SrnPnic, vcfroot.SOUNDS.PanicMde.AllowUse)
            };

            dual_siren = false;

            _mainSiren = new MainSiren(ref _tones);

            if (data != null)
            {
                SetData(data);
            }
            ElsUiPanel.SetUiDesc(_mainSiren.currentTone.Type, "SRN");
            ElsUiPanel.SetUiDesc("--", "HRN");
        }
Exemple #2
0
        public Siren(ELSVehicle vehicle, Vcfroot vcfroot, IPatterns patt)
        {
            _vcf = vcfroot;
            if (_vcf is null)
            {
                Utils.ReleaseWriteLine($"VCF for vehicle {vehicle?.Vehicle?.DisplayName} with netId {vehicle?.NetworkId} is null!");
                return;
            }
            _elsVehicle        = vehicle;
            _patternController = patt;
            Utils.DebugWriteLine($"{_vcf.SOUNDS.MainHorn.AudioString}");
            Utils.DebugWriteLine($"{_vcf.SOUNDS.SrnTone1.AudioString}");
            Utils.DebugWriteLine($"{_vcf.SOUNDS.SrnTone2.AudioString}");
            Utils.DebugWriteLine($"{_vcf.SOUNDS.SrnTone3.AudioString}");
            Utils.DebugWriteLine($"{_vcf.SOUNDS.SrnTone4.AudioString}");

            _tones = new Tones
            {
                horn  = new Tone(_vcf.SOUNDS.MainHorn.AudioString, _elsVehicle, ToneType.Horn, true, soundSet: _vcf.SOUNDS.MainHorn.SoundSet),
                tone1 = new Tone(_vcf.SOUNDS.SrnTone1.AudioString, _elsVehicle, ToneType.SrnTon1, _vcf.SOUNDS.SrnTone1.AllowUse, soundSet: _vcf.SOUNDS.SrnTone1.SoundSet),
                tone2 = new Tone(_vcf.SOUNDS.SrnTone2.AudioString, _elsVehicle, ToneType.SrnTon2, _vcf.SOUNDS.SrnTone2.AllowUse, soundSet: _vcf.SOUNDS.SrnTone2.SoundSet),
                tone3 = new Tone(_vcf.SOUNDS.SrnTone3.AudioString, _elsVehicle, ToneType.SrnTon3, _vcf.SOUNDS.SrnTone3.AllowUse, soundSet: _vcf.SOUNDS.SrnTone3.SoundSet),
                tone4 = new Tone(_vcf.SOUNDS.SrnTone4.AudioString, _elsVehicle, ToneType.SrnTon4, _vcf.SOUNDS.SrnTone4.AllowUse, soundSet: _vcf.SOUNDS.SrnTone4.SoundSet),
            };

            _mainSiren = new MainSiren(ref _tones);
            dual_siren = false;

            ElsUiPanel.SetUiDesc(_mainSiren.MainTones[_mainSiren.currentTone].Type, "SRN");
            ElsUiPanel.SetUiDesc("--", "HRN");
        }
Exemple #3
0
 internal Lights(Vehicle vehicle, Vcfroot vcfroot, [Optional] IDictionary <string, object> data)
 {
     _vcfroot = vcfroot;
     _vehicle = vehicle;
     AddAllValidLightExtras();
     LightStagesSetup();
     SetupPatternsPrm();
     SetupSecPatterns();
     SetupWrnPatterns();
 }
Exemple #4
0
 internal Lights(ELSVehicle vehicle, Vcfroot vcfroot)
 {
     Vcfroot    = vcfroot;
     ElsVehicle = vehicle;
     LightStagesSetup();
     if (Vehicle.Exists(ElsVehicle.Vehicle))
     {
         Init();
     }
 }
Exemple #5
0
 internal Lights(Vehicle vehicle, Vcfroot vcfroot, [Optional] LightFSData data)
 {
     _vcfroot = vcfroot;
     _vehicle = vehicle;
     AddAllValidLightExtras();
     LightStagesSetup();
     SetupPatternsPrm();
     SetupSecPatterns();
     SetupWrnPatterns();
     if (!data.Equals(null))
     {
         SetData(data);
     }
 }
Exemple #6
0
        public ELSVehicle(int handle, [Optional] IDictionary <string, object> data) : base(handle)
        {
            _vehicle = new Vehicle(handle);
            ModelLoaded();
            lastdrivetime = Game.GameTime;
            API.SetVehRadioStation(_vehicle.Handle, "OFF");
            API.SetVehicleRadioEnabled(_vehicle.Handle, false);
            if (_vehicle.DisplayName == "CARNOTFOUND")
            {
                throw new Exception("ELSVehicle.cs:Vehicle not found");
            }
            else if (_vehicle.GetNetworkId() == 0)
            {
                throw new Exception("ELSVehicle.cs:NetworkId is 0");
            }
            else if (VCF.ELSVehicle.ContainsKey(_vehicle.Model))
            {
                _vcf = VCF.ELSVehicle[_vehicle.Model].root;
            }
            try
            {
                Function.Call((Hash)0x5f3a3574, _vehicle.Handle, true);
            }
            catch (Exception e)
            {
                Utils.ReleaseWriteLine("ELSVehicle.cs:Repair Fix is not enabled on this client");
            }


            _light = new Light.Lights(_vehicle, _vcf, (IDictionary <string, object>)data?["light"]);
            _siren = new Siren.Siren(_vehicle, _vcf, (IDictionary <string, object>)data?["siren"], _light);
            _light.SetGTASirens(false);
            //_vehicle.SetExistOnAllMachines(true);
            cachedNetId = _vehicle.GetNetworkId();
#if DEBUG
            CitizenFX.Core.Debug.WriteLine(CitizenFX.Core.Native.API.IsEntityAMissionEntity(_vehicle.Handle).ToString());

            CitizenFX.Core.Debug.WriteLine($"ELSVehicle.cs:registering netid:{_vehicle.GetNetworkId()}\n" +
                                           $"Does entity belong to this script:{CitizenFX.Core.Native.API.DoesEntityBelongToThisScript(_vehicle.Handle, false)}");
            CitizenFX.Core.Debug.WriteLine($"ELSVehicle.cs:created vehicle");
#endif
        }
Exemple #7
0
        public ELSVehicle(int handle, [Optional] ELSVehicleFSData data) : base(handle)
        {
            _vehicle = new Vehicle(handle);
            if (!_vehicle.Exists())
            {
                return;
            }
            ModelLoaded();
            lastdrivetime = Game.GameTime;
            API.SetVehRadioStation(_vehicle.Handle, "OFF");
            API.SetVehicleRadioEnabled(_vehicle.Handle, false);

            if (_vehicle.DisplayName == "CARNOTFOUND")
            {
                throw new Exception("ELSVehicle.cs: Vehicle not found");
            }
            else if (VCF.ELSVehicle.ContainsKey(_vehicle.Model))
            {
                _vcf = VCF.ELSVehicle[_vehicle.Model].root;
            }
            if (API.DecorExistOn(_vehicle.Handle, "elsplus_id"))
            {
                cachedElsID = _vehicle.GetElsId();
            }
            else
            {
                Utils.ReleaseWriteLine("ELSVehicle.cs: Vehicle is being created without a els id attempting to set now");
                if (data.Id > 0)
                {
                    cachedElsID = data.Id;
                    API.DecorSetInt(_vehicle.Handle, "elsplus_id", cachedElsID);
                }
            }
            try
            {
                Function.Call((Hash)0x5f3a3574, _vehicle.Handle, true);
            }
            catch (Exception e)
            {
                Utils.ReleaseWriteLine("ELSVehicle.cs: Repair Fix is not enabled on this client");
            }
            Utils.DebugWriteLine($"ELS Vehicle Data: {JsonConvert.SerializeObject(data)}");
            if (data.Id.Equals(null))
            {
                _light = new Light.Lights(_vehicle, _vcf);
                _siren = new Siren.Siren(_vehicle, _vcf, _light);
            }
            else
            {
                _light = new Light.Lights(_vehicle, _vcf, data.Light);
                _siren = new Siren.Siren(_vehicle, _vcf, _light, data.Siren);
            }

            _light.SetGTASirens(false);


            Utils.DebugWriteLine(API.IsEntityAMissionEntity(_vehicle.Handle).ToString());
            Utils.DebugWriteLine($"ELSVehicle.cs:registering \n" +
                                 $"Does entity belong to this script:{API.DoesEntityBelongToThisScript(_vehicle.Handle, false)}");
            Utils.DebugWriteLine($"ELSVehicle.cs:created vehicle");
            FullSync.FullSyncManager.SendDataBroadcast(JsonConvert.SerializeObject(GetData()), Game.Player.ServerId);
        }