예제 #1
0
파일: ELS.cs 프로젝트: timnboys/ELS-FiveM-1
 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["onPlayerJoining"] += new Action(() =>
     {
     });
     EventHandlers["ELS:FullSync:NewSpawnWithData"] += new Action <System.Dynamic.ExpandoObject>((a) =>
     {
         _vehicleManager.SyncAllVehiclesOnFirstSpawn(a);
         Tick -= Class1_Tick;
         Tick += Class1_Tick;
     });
     EventHandlers["ELS:FullSync:NewSpawn"] += new Action(() =>
     {
         Tick -= Class1_Tick;
         Tick += Class1_Tick;
     });
     //Take in data and apply it
     EventHandlers["ELS:NewFullSyncData"] += new Action <IDictionary <string, object> >(_vehicleManager.SetVehicleSyncData);
 }
예제 #2
0
        private void SetupConnections()
        {
            API.RegisterKeyMapping("togglehazard", "Alarm lichten", "keyboard", "");
            API.RegisterKeyMapping("toggleleftblinker", "Linker knipperlicht", "keyboard", "MINUS");
            API.RegisterKeyMapping("togglerightblinker", "Rechts knipperlicht", "keyboard", "EQUALS");
            EventHandlers["onClientResourceStop"] += new Action <string>(async(string obj) =>
            {
                if (obj == Function.Call <string>(Hash.GET_CURRENT_RESOURCE_NAME))
                {
                    VehicleManager.Instance.CleanUP();
                    _FileLoader.UnLoadFilesFromScript(obj);
                }
            });

            EventHandlers["ELS:FullSync:NewSpawnWithData"] += new Action <IDictionary <string, object> >((a) =>
            {
                VehicleManager.Instance.SyncAllVehiclesOnFirstSpawn(a);
            });
        }
예제 #3
0
        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);
        }
예제 #4
0
파일: ELS.cs 프로젝트: dexslab/ELS-FiveM
        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);
                Tick -= Class1_Tick;
                Tick += Class1_Tick;
            });
            EventHandlers["ELS:FullSync:NewSpawn"] += new Action(() =>
            {
                Tick -= Class1_Tick;
                Tick += Class1_Tick;
            });

            EventHandlers["ELS:VehicleEntered"] += new Action <int>((veh) =>
            {
                Utils.DebugWriteLine("Vehicle entered");
                Vehicle vehicle = new Vehicle(veh);
                if (vehicle.IsEls() && VehicleManager.vehicleList.ContainsKey(vehicle.GetNetworkId()))
                {
                    Utils.DebugWriteLine("ELS Vehicle entered syncing UI");
                    VehicleManager.SyncUI(vehicle.GetNetworkId());
                }
            });
            //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) =>
            {
                if (arguments.Count != 1)
                {
                    return;
                }
                if (arguments[0].Equals("enable"))
                {
                    ElsUiPanel.EnableUI();
                }
                else if (arguments[0].Equals("disable"))
                {
                    ElsUiPanel.DisableUI();
                }
                else if (arguments[0].Equals("show"))
                {
                    ElsUiPanel.ShowUI();
                }
            }), 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);
        }