Exemplo n.º 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 == Function.Call <string>(Hash.GET_CURRENT_RESOURCE_NAME))
                {
                    //await Delay(500);
                    try
                    {
                        _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);
                        TriggerServerEvent("ELS:FullSync:Request:All", Game.Player.ServerId);
                        ElsUiPanel.InitData();
                        ElsUiPanel.DisableUI();
                        SetupExports();
                    }
                    catch (Exception e)
                    {
                        TriggerServerEvent($"ONDEBUG", e.ToString());
                        Screen.ShowNotification($"ERROR:{e.Message}");
                        Screen.ShowNotification($"ERROR:{e.StackTrace}");
                        Tick -= Class1_Tick;
                        throw;
                    }
                }
                else
                {
                    try
                    {
                        _FileLoader.RunLoader(obj);
                    }
                    catch (Exception e)
                    {
                        TriggerServerEvent($"ONDEBUG", e.ToString());
                        Screen.ShowNotification($"ERROR:{e.Message}");
                        Screen.ShowNotification($"ERROR:{e.StackTrace}");
                    }
                }
            });
        }
Exemplo n.º 2
0
        public ELS()
        {
            bool Loaded = false;

            _controlConfiguration = new ElsConfiguration();
            _FileLoader           = new FileLoader(this);
            _vehicleManager       = new VehicleManager();
            API.DecorRegister("elsplus_id", 3);
            API.DecorRegister("elsplus_registering", 3);
            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();
                        Global.RegisteredSoundBanks = new List <string>();
                        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);
                        API.SetVisualSettingFloat("car.defaultlight.night.emissive.on", Global.NightLtBrightness);
                        API.SetVisualSettingFloat("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}");
                    }
                }
            });
        }
Exemplo n.º 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}");
                    }
                }
            });
        }