internal void SetSaveSettings(UserSettings.ELSUserVehicle veh) { _light.CurrentPrmPattern = veh.PrmPatt; _light.CurrentSecPattern = veh.SecPatt; _light.CurrentWrnPattern = veh.WrnPatt; int id = _vehicle.GetElsId(); VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangePrmPatt, id, Game.Player.ServerId); VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangeSecPatt, id, Game.Player.ServerId); VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangeWrnPatt, id, Game.Player.ServerId); switch (veh.Siren) { case "WL": _siren._mainSiren.setMainTone(0); break; case "YP": _siren._mainSiren.setMainTone(1); break; case "A1": _siren._mainSiren.setMainTone(2); break; case "A2": _siren._mainSiren.setMainTone(3); break; } VehicleManager.SyncRequestReply(RemoteEventManager.Commands.MainSiren, id, Game.Player.ServerId); }
internal void SetSaveSettings(UserSettings.ELSUserVehicle veh) { _light.CurrentPrmPattern = veh.PrmPatt; _light.CurrentSecPattern = veh.SecPatt; _light.CurrentWrnPattern = veh.WrnPatt; VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangePrmPatt, this.GetNetworkId(), Game.Player.ServerId); VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangeSecPatt, this.GetNetworkId(), Game.Player.ServerId); VehicleManager.SyncRequestReply(RemoteEventManager.Commands.ChangeWrnPatt, this.GetNetworkId(), Game.Player.ServerId); switch (veh.Siren) { case "WL": _siren._mainSiren.setMainTone(_siren._tones.tone1); break; case "YP": _siren._mainSiren.setMainTone(_siren._tones.tone2); break; case "A1": _siren._mainSiren.setMainTone(_siren._tones.tone3); break; case "A2": _siren._mainSiren.setMainTone(_siren._tones.tone4); break; } VehicleManager.SyncRequestReply(RemoteEventManager.Commands.MainSiren, this.GetNetworkId(), Game.Player.ServerId); }
internal void GetSaveSettings() { UserSettings.ELSUserVehicle veh = new UserSettings.ELSUserVehicle() { ServerId = ELS.ServerId, PrmPatt = _light.CurrentPrmPattern, SecPatt = _light.CurrentSecPattern, WrnPatt = _light.CurrentWrnPattern, Siren = _siren._mainSiren.MainTones[_siren._mainSiren.currentTone].Type, Model = _vehicle.Model.Hash }; ELS.userSettings.SaveVehicles(veh); }
private void SetupConnections() { EventHandlers["onClientResourceStop"] += new Action <string>(async(string obj) => { if (obj == Function.Call <string>(Hash.GET_CURRENT_RESOURCE_NAME)) { _vehicleManager.CleanUP(); _FileLoader.UnLoadFilesFromScript(obj); } }); //command that siren state has changed. //recieves a command //EventHandlers["ELS:SirenUpdated"] += new Action<string, int, int, bool>(_vehicleManager.UpdateRemoteSirens); EventHandlers["ELS:SpawnCar"] += new Action <string>((veh) => { SpawnCar(veh); }); EventHandlers["ELS:VcfSync:Client"] += new Action <List <dynamic> >((vcfs) => { VCF.ParseVcfs(vcfs); }); EventHandlers.Add("ELS:PatternSync:Client", new Action <List <dynamic> >((patterns) => { VCF.ParsePatterns(patterns); })); EventHandlers["ELS:FullSync:NewSpawnWithData"] += new Action <System.Dynamic.ExpandoObject>((a) => { _vehicleManager.SyncAllVehiclesOnFirstSpawn(a); }); EventHandlers["ELS:FullSync:NewSpawn"] += new Action(() => { Tick -= Class1_Tick; Tick += Class1_Tick; }); EventHandlers.Add("playerSpawned", new Action(() => { TriggerServerEvent("ELS:FullSync:Request:All", Game.Player.ServerId); })); EventHandlers["ELS:VehicleEntered"] += new Action <int>((veh) => { Utils.DebugWriteLine("Vehicle entered checking list"); Vehicle vehicle = new Vehicle(veh); Delay(1000); try { if (vehicle.Exists() && vehicle.IsEls()) { if ((vehicle.GetNetworkId() == LocalPlayer.Character.CurrentVehicle.GetNetworkId())) { Utils.DebugWriteLine("Vehicle is in list moving on"); Utils.DebugWriteLine("ELS Vehicle entered syncing UI"); lastVehicle = vehicle.GetNetworkId(); if (userSettings.uiSettings.enabled) { ElsUiPanel.ShowUI(); } VehicleManager.SyncUI(vehicle.GetNetworkId()); UserSettings.ELSUserVehicle usrVeh = userSettings.savedVehicles.Find(uveh => uveh.Model == vehicle.Model.Hash && uveh.ServerId == ServerId); Utils.DebugWriteLine($"got usrveh of {usrVeh.Model} on server {usrVeh.ServerId}m"); if (ServerId.Equals(usrVeh.ServerId)) { Utils.DebugWrite("Got Saved Vehicle Settings applying"); VehicleManager.vehicleList[vehicle.GetNetworkId()].SetSaveSettings(usrVeh); } VehicleManager.vehicleList[vehicle.GetNetworkId()].SetInofVeh(); } Utils.DebugWriteLine($"Vehicle {vehicle.GetNetworkId()}({Game.PlayerPed.CurrentVehicle.GetNetworkId()}) entered"); } } catch (Exception e) { Utils.ReleaseWriteLine("Exception caught via vehicle entered"); } }); EventHandlers["ELS:VehicleExited"] += new Action <int>((veh) => { Vehicle vehicle = new Vehicle(veh); try { if (vehicle.Exists() && vehicle.IsEls()) { if (VehicleManager.vehicleList.ContainsKey(vehicle.GetNetworkId()) && (vehicle.GetNetworkId() == lastVehicle)) { if (Global.DisableSirenOnExit) { VehicleManager.vehicleList[vehicle.GetNetworkId()].DisableSiren(); } Utils.DebugWriteLine("save settings for vehicle it"); VehicleManager.vehicleList[vehicle.GetNetworkId()].GetSaveSettings(); VehicleManager.vehicleList[vehicle.GetNetworkId()].SetOutofVeh(); } Utils.DebugWriteLine($"Vehicle {vehicle.GetNetworkId()}({Game.PlayerPed.LastVehicle.GetNetworkId()}) exited"); } } catch (Exception e) { Utils.ReleaseWriteLine("Exception caught via vehicle exited"); } }); //Take in data and apply it EventHandlers["ELS:NewFullSyncData"] += new Action <IDictionary <string, object>, int>(_vehicleManager.SetVehicleSyncData); API.RegisterCommand("vcfsync", new Action <int, List <object>, string>((source, arguments, raw) => { TriggerServerEvent("ELS:VcfSync:Server", Game.Player.ServerId); }), false); API.RegisterCommand("elsui", new Action <int, List <object>, string>((source, arguments, raw) => { Task task = new Task(() => userSettings.SaveUI(true)); if (arguments.Count != 1) { return; } switch (arguments[0].ToString().ToLower()) { case "enable": ElsUiPanel.EnableUI(); break; case "disable": ElsUiPanel.DisableUI(); userSettings.uiSettings.enabled = false; break; case "show": ElsUiPanel.ShowUI(); userSettings.uiSettings.enabled = true; break; case "whelen": userSettings.uiSettings.currentUI = UserSettings.ElsUi.Whelen; break; case "new": userSettings.uiSettings.currentUI = UserSettings.ElsUi.NewHotness; break; case "old": userSettings.uiSettings.currentUI = UserSettings.ElsUi.OldandBusted; break; } task.Start(); }), false); API.RegisterCommand("elslist", new Action <int, List <object>, string>((source, args, raw) => { var listString = ""; listString += $"Available ELS Vehicles\n" + $"----------------------\n"; foreach (var entry in VCF.ELSVehicle.Values) { if (entry.modelHash.IsValid) { listString += $"{System.IO.Path.GetFileNameWithoutExtension(entry.filename)}\n"; } } CitizenFX.Core.Debug.WriteLine(listString); }), false); }