Example #1
0
        public ELS()
        {
            bool Loaded = false;

            _controlConfiguration = new ElsConfiguration();
            _FileLoader           = new FileLoader(this);
            _vehicleManager       = new VehicleManager();
            EventHandlers["onClientResourceStart"] += new Action <string>((string obj) =>
            {
                //TODO rewrite loader so that it
                if (obj == CurrentResourceName())
                {
                    try
                    {
                        ServerId          = API.GetConvar("ElsServerId", null);
                        userSettings      = new UserSettings();
                        Task settingsTask = new Task(() => userSettings.LoadUserSettings());
                        Utils.ReleaseWriteLine($"Welcome to ELS Plus on {ServerId} using version {Assembly.GetExecutingAssembly().GetName().Version.ToString()}");
                        settingsTask.Start();
                        _FileLoader.RunLoader(obj);
                        //Screen.ShowNotification($"Welcome {LocalPlayer.Name}\n ELS Plus\n\n ELS Plus is Licensed under LGPL 3.0\n\nMore inforomation can be found at http://els.friendsincode.com");
                        SetupConnections();
                        TriggerServerEvent("ELS:VcfSync:Server", Game.Player.ServerId);
                        SetupExports();
                        Tick -= Class1_Tick;
                        Tick += Class1_Tick;
                        Function.Call((Hash)3520272001, "car.defaultlight.night.emissive.on", Global.NightLtBrightness);
                        Function.Call((Hash)3520272001, "car.defaultlight.day.emissive.on", Global.DayLtBrightness);
                    }
                    catch (Exception e)
                    {
                        TriggerServerEvent($"ONDEBUG", e.ToString());
                        Screen.ShowNotification($"ERROR:{e.Message}");
                        Screen.ShowNotification($"ERROR:{e.StackTrace}");
                        Tick -= Class1_Tick;
                        Utils.ReleaseWriteLine($"Error: {e.Message}");
                    }
                }
            });
        }
Example #2
0
        public ELS()
        {
            controlConfiguration = new configuration.ControlConfiguration();
            _FileLoader          = new FileLoader(this);
            _sirenManager        = new SirenManager();

            EventHandlers["onClientResourceStart"] += new Action <string>(
                (string obj) =>
            {
                try
                {
                    if (obj != CurrentResourceName())
                    {
                        _FileLoader.RunLoadeer(obj);
                    }
                    else if (obj == CurrentResourceName())
                    {
                        Screen.ShowNotification($"Welcome {LocalPlayer.Name}  to ELS FiveM\n\n ELS FiveM is Licensed under LGPL 3.0\n\nMore inforomation can be found at http://fivem-scripts.net");

                        // BaseScript.Delay(5000);
                        _FileLoader.RunLoadeer(obj);
                        Tick += Class1_Tick;
                    }
                }
                catch (Exception e)
                {
                    TriggerServerEvent($"ONDEBUG", e.ToString());
                    Screen.ShowNotification($"ERROR:{e.Message}");
                    Tick -= Class1_Tick;
                    throw;
                }

                //_spotLight= new SpotLight();
            });
            EventHandlers["ELS:SirenUpdated"] += new Action <int, string, bool>(_sirenManager.UpdateSirens);

            EventHandlers["onPlayerJoining"] += new Action(() =>
            {
            });
        }
Example #3
0
        public ELS()
        {
            if (API.GetConvar("dev_server", "false") == "true" || API.GetConvar("test_server", "false") == "true")
            {
                Utils.IsDeveloper = true;
                Utils.ReleaseWriteLine("Debug logging enabled!");
            }
            bool Loaded = false;

            _controlConfiguration = new ElsConfiguration();
            _FileLoader           = new FileLoader(this);
            EventHandlers["onClientResourceStart"] += new Action <string>(async(string obj) =>
            {
                if (obj == CurrentResourceName())
                {
                    Utils.Debug = bool.Parse(API.GetConvar("elsplus_debug", "false"));
                    try
                    {
                        await Delay(100);
                        ServerId     = API.GetConvar("ElsServerId", null);
                        userSettings = new UserSettings();
                        await Delay(0);
                        Task settingsTask = new Task(() => userSettings.LoadUserSettings());
                        await Delay(0);
                        Utils.ReleaseWriteLine($"Welcome to ELS Plus on {ServerId} using version {Assembly.GetExecutingAssembly().GetName().Version}");
                        settingsTask.Start();
                        await Delay(250);
                        _FileLoader.RunLoader(obj);
                        await Delay(250);
                        SetupConnections();
                        await Delay(250);
                        VcfSync.CheckResources();
                        VCF.ParseVcfs(VcfSync.VcfData);
                        CustomPatterns.CheckCustomPatterns();
                        VCF.ParsePatterns(CustomPatterns.Patterns);
                        await Delay(250);
                        Tick -= Class1_Tick;
                        Tick += Class1_Tick;
                        await Delay(1000);
                        if (float.TryParse(API.GetResourceKvpString("daybrightness"), out var dayValue))
                        {
                            Function.Call((Hash)3520272001, "car.defaultlight.day.emissive.on", dayValue);
                        }
                        else
                        {
                            Function.Call((Hash)3520272001, "car.defaultlight.day.emissive.on", Global.DayLtBrightness);
                        }
                        if (float.TryParse(API.GetResourceKvpString("nightbrightness"), out var nightValue))
                        {
                            Function.Call((Hash)3520272001, "car.defaultlight.night.emissive.on", nightValue);
                        }
                        else
                        {
                            Function.Call((Hash)3520272001, "car.defaultlight.night.emissive.on", Global.NightLtBrightness);
                        }

                        API.RequestScriptAudioBank("DLC_WMSIRENS\\SIRENPACK_ONE", false);
                    }
                    catch (Exception e)
                    {
                        Screen.ShowNotification($"ERROR:{e.Message}");
                        Screen.ShowNotification($"ERROR:{e.StackTrace}");
                        Tick -= Class1_Tick;
                        Utils.ReleaseWriteLine($"ERROR:{e.StackTrace}");
                        Utils.ReleaseWriteLine($"Error: {e.Message}");
                    }
                }
            });
        }