Esempio n. 1
0
 public PaymentHandler(Server server) : base(server)
 {
     CommandRegister.RegisterCommand("setpaymenttype|setpaymentmethod|paywith", OnPaymentMethodSet);
     server.RegisterEventHandler("Job.RequestDeliveryPayment", new Action <Player, List <object>, List <object>, string>(OnDeliveryPayReq));
     server.RegisterEventHandler("Job.RequestPayForJob", new Action <Player, string, string>(OnJobPayReq));
     server.RegisterEventHandler("Job.RequestRemoteJobPayment", new Action <Player, int, string>(OnRemoteJobPay));
     server.RegisterEventHandler("Payment.PayForItem", new Action <Player, int, string>(OnRemotePay));
     server.RegisterEventHandler("Payment.CanPayForItem", new Action <Player, int>(OnCheckCanPay));
     server.RegisterEventHandler("Payment.GivePlayerCash", new Action <Player, int, int>(OnGiveCash));
     server.RegisterTickHandler(PaycheckTick);
 }
        public TimeWeatherSync(Server server) : base(server)
        {
            server.RegisterEventHandler("Sync.RequestTime", new Action <Player>(OnRequestTime));
            server.RegisterEventHandler("Sync.RequestWeather", new Action <Player>(OnRequestWeather));
            server.RegisterTickHandler(TimeTick);
            server.RegisterTickHandler(WeatherTick);

            CommandRegister.RegisterAdminCommand("freezetime", OnFreezeTime, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("time", OnSetTime, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("weather", OnSetWeather, AdminLevel.Admin);
        }
Esempio n. 3
0
 public SkinHandler(Client client) : base(client)
 {
     client.RegisterEventHandler("Skin.LoadPlayerSkin", new Action <dynamic>(data =>
     {
         CharacterEditorMenu.handleSkinCreate(data == null ? CharacterEditorMenu.skinData : data);
     }));
     client.RegisterEventHandler("Skin.StartCharacterCreation", new Action <int>(async playerHome =>
     {
         CharacterEditorMenu charMenu = new CharacterEditorMenu();
         while (charMenu.Observer.CurrentMenu != null)
         {
             Client.Get <Arrest>().DisableActions();
             Game.PlayerPed.Task.ClearAll();
             await BaseScript.Delay(0);
         }
         //if (playerHome != 0) TriggerEvent("spawnPlayerHome", playerHome);
     }));
     client.RegisterEventHandler("Skin.UpdatePlayerSkinData", new Action <dynamic>(skinData => CharacterEditorMenu.skinData = skinData));
     client.RegisterEventHandler("Skin.SaveCurrentOutfit", new Action <string>(handleOutfitCreate));
     client.Get <InteractionUI>().RegisterInteractionMenuItem(new MenuFramework.MenuItemStandard
     {
         Title      = "Clothing Store",
         OnActivate = state =>
         {
             new CharacterEditorMenu(true);
             InteractionUI.Observer.CloseMenu(true);
         }
     }, () => clothingStoreLocaitons.Any(o => o.DistanceToSquared(Game.PlayerPed.Position) < 5.0f), 500);
     BlipHandler.AddBlip("Clothing store", clothingStoreLocaitons, new BlipOptions
     {
         Sprite = BlipSprite.Clothes
     });
     MarkerHandler.AddMarker(clothingStoreLocaitons);
     client.RegisterEventHandler("Skin.RefreshSkin", new Action(RefreshPlayerSkin));
     client.RegisterEventHandler("Player.OnLoginComplete", new Action(RefreshPlayerSkin));
     client.RegisterEventHandler("Player.CheckForInteraction", new Action(() =>
     {
         if (clothingStoreLocaitons.Any(o => o.DistanceToSquared(Game.PlayerPed.Position) < 5.0f))
         {
             new CharacterEditorMenu(true);
         }
     }));
     client.RegisterEventHandler("Player.OnSkinLoaded", new Action(() => canRefreshSkin = false));
     CommandRegister.RegisterCommand("refreshskin", async cmd =>
     {
         if (!canRefreshSkin)
         {
             return;
         }
         await cmd.Session.UpdateData("Character.SkinData");
         RefreshPlayerSkin();
     });
 }
Esempio n. 4
0
        public void TestCommandRegister0()
        {
            ICallTester callTester = Substitute.For <ICallTester>();

            Command command = new Command();
            CommandRegister <ICallTester> cr = new CommandRegister <ICallTester>(command, caller => caller.Function1());

            cr.Register(0, callTester);
            command.Run("0Function1", new string[0]);
            callTester.Received(1).Function1();
            cr.Unregister(0);
        }
 public LoginHandler(Server server) : base(server)
 {
     server.RegisterEventHandler("Login.RequestCharacters", new Action <Player>(OnCharactersRequest));
     server.RegisterEventHandler("Login.CreateCharacter", new Action <Player, string, string, string>(OnCreateRequest));
     server.RegisterEventHandler("Login.LoadCharacter", new Action <Player, int>(OnLoadRequest));
     server.RegisterEventHandler("Login.DeleteCharacter", new Action <Player, int>(OnCharacterDelete));
     CommandRegister.RegisterAdminCommand("logout", cmd => OnCharactersRequest(cmd.Player), AdminLevel.Developer);
     CommandRegister.RegisterCommand("showlogin", cmd =>
     {
         OnCharactersRequest(cmd.Player);
     });
 }
Esempio n. 6
0
        /// <summary>
        /// Setups this hardware device driver
        /// </summary>
        /// <returns></returns>
        public override bool Setup(IHardwareResources hardwareResources)
        {
            this.hardwareResources = hardwareResources;
            base.name = "TEST_" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X");

            TestPort = hardwareResources.GetIOPort(0, 0);

            Command = new CommandRegister(TestPort, 8);

            Command.Enabled = true;

            return true;
        }
Esempio n. 7
0
        public JobCalling()
        {
            CommandRegister.RegisterCommand("taxi", OnTaxiMessage);
            CommandRegister.RegisterJobCommand("taxir", OnTaxiRespond, JobType.Taxi);

            CommandRegister.RegisterJobCommand("towr", OnTowRespond, JobType.Tow);
            CommandRegister.RegisterCommand("calltow", OnCallTow);

            CommandRegister.RegisterCommand("taxis", CheckAvailableTaxis);
            CommandRegister.RegisterCommand("tows", CheckAvailableTows);

            Server.RegisterEventHandler("Job.SendTowVehicle", new Action <Player, string>(OnRecieveTow));
        }
Esempio n. 8
0
        /// <summary>
        /// Setups this hardware device driver
        /// </summary>
        /// <returns></returns>
        public override bool Setup(IHardwareResources hardwareResources)
        {
            this.hardwareResources = hardwareResources;
            base.name = "TEST_" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X");

            TestPort = hardwareResources.GetIOPort(0, 0);

            Command = new CommandRegister(TestPort, 8);

            Command.Enabled = true;

            return(true);
        }
 public ToggleableClothing(Client client) : base(client)
 {
     client.RegisterEventHandler("Player.OnSkinLoaded", new Action(() =>
     {
         glassesPropIndex    = Game.PlayerPed.Style[PedProps.Glasses].Index;
         glassesTextureIndex = Game.PlayerPed.Style[PedProps.Glasses].Index;
         hatPropIndex        = Game.PlayerPed.Style[PedProps.Hats].Index;
         hatTextureIndex     = Game.PlayerPed.Style[PedProps.Hats].TextureIndex;
         maskPropIndex       = Game.PlayerPed.Style[PedComponents.Head].Index;
         maskTextureIndex    = Game.PlayerPed.Style[PedComponents.Head].TextureIndex;
     }));
     CommandRegister.RegisterCommand("glasses", handleGlassesCommand);
     CommandRegister.RegisterCommand("hat", handleHatCommand);
     CommandRegister.RegisterCommand("mask", handleMaskCommand);
 }
 public CallBlips(Client client) : base(client)
 {
     client.RegisterEventHandler("Blip.CreateEmergencyBlip", new Action <int>(CreateEmgerencyBlip));
     client.RegisterEventHandler("Blip.CreateJobBlip", new Action <string, int, int>(CreateJobBlip));
     client.RegisterTickHandler(RemoveBlipTick);
     CommandRegister.RegisterCommand("remblip|delblip", cmd =>
     {
         var targetBlip = cmd.GetArgAs(0, 0);
         if (playersBlips.ContainsKey(targetBlip))
         {
             playersBlips[targetBlip].Delete();
             playersBlips.Remove(targetBlip);
         }
     });
 }
Esempio n. 11
0
        public DevEnviroment(Server server) : base(server)
        {
            IsDebugInstance      = GetConvar("mg_debugInstance", "false") == "true";
            EnableVerboseLogging = GetConvar("mg_enableVerboseLogging", "false") == "true";

            CommandRegister.RegisterAdminCommand("dev", OnDevCommand, AdminLevel.Developer);
            CommandRegister.RegisterAdminCommand("debug", OnSetDebug, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("verbose", OnSetVerbose, AdminLevel.SuperAdmin);

            RegisterDevCommand("eui", OnSetEntityUI);
            RegisterDevCommand("removevehaccess", OnRemoveVehicleAccess);

            Log.Info($"Debug instance is {(IsDebugInstance ? "enabled" : "disabled")}");
            Log.Info($"Verbose logging is {(EnableVerboseLogging ? "enabled" : "disabled")}");
        }
Esempio n. 12
0
        public InventoryMenuHandler(Client client) : base(client)
        {
            RegisterInventoryMenu("PlayerInventory", new PlayerInventoryMenu(""));
            RegisterInventoryMenu("VehicleInventory", new VehicleInventoryMenu(""));
            RegisterInventoryMenu("PropertyInventory", new PropertyInventoryMenu(""));

            CommandRegister.RegisterCommand("inv|inventory", cmd =>
            {
                OpenInventoryMenu("PlayerInventory");
            });
            CommandRegister.RegisterCommand("vehinv|vehicleinventory", new Action <Command>(cmd =>
            {
                OpenInventoryMenu("VehicleInventory");
            }));
        }
        public VoipRanges(Client client) : base(client)
        {
            CommandRegister.RegisterCommand("voip", changeVoipRange);
            voipTypes.ToList().ForEach(o => voipRanges.Add(o.Value));
            client.RegisterTickHandler(OnTick);
            voiceText = new ScreenText("Voice: ", 31, 1026, 0.25f, TextThread, System.Drawing.Color.FromArgb(255, 200, 200, 200), Font.ChaletLondon, Alignment.Left);
            rangeText = new ScreenText(currentVoipName, 78, 1026, 0.25f, VoipRangeTick, System.Drawing.Color.FromArgb(255, 200, 200, 200), Font.ChaletLondon, Alignment.Left);

            CitizenFX.Core.Native.API.NetworkSetTalkerProximity(voipTypes["Nearby"]);
            client.RegisterEventHandler("Session.Loaded", new Action(() =>
            {
                CitizenFX.Core.Native.API.NetworkSetTalkerProximity(voipTypes["Nearby"]);
                CitizenFX.Core.Native.API.NetworkClearVoiceChannel();
            }));
        }
        public SessionManager(Server server) : base(server)
        {
            server.RegisterEventHandler("playerConnecting", new Action <Player, string, dynamic, dynamic>(OnInitialConnect));
            server.RegisterEventHandler("playerDropped", new Action <Player, string>(OnPlayerDropped));
            server.RegisterEventHandler("Session.Loaded", new Action <Player>(OnPlayerLoaded));
            server.RegisterEventHandler("Session.UpdateClientData", new Action <Player, string, string>(OnDataUpdate));
            server.RegisterEventHandler("Session.SetPlayerStatus", new Action <Player, string, dynamic>(OnSetStatus)); // TEMP
            server.RegisterEventHandler("chatMessage", new Action <int, string, string>(OnChatMessageEntered));
            server.RegisterLocalEvent("Log.ToDatabase", new Action <string, string, string, string>(OnLogData));
            server.RegisterTickHandler(SaveTick);
            CommandRegister.RegisterAdminCommand("listuser", cmd =>
            {
                var player = GetPlayer(cmd.GetArgAs(0, 0));
                if (player == null)
                {
                    return;
                }

                Log.Info($"Server ID: {player.ServerID}");
                Log.Info($"Player name: {player.PlayerName}");
                Log.Info($"Player ped handle: {player.Ped?.Handle}");
                Log.Info($"Position: {player.Position}");
                foreach (var kvp in player.GlobalData)
                {
                    Log.Info($"{kvp.Key} - {kvp.Value}");
                }

                foreach (var kvp in player.LocalData)
                {
                    Log.Info($"{kvp.Key} - {kvp.Value}");
                }

                foreach (var kvp in player.ServerData)
                {
                    Log.Info($"{kvp.Key} - {kvp.Value}");
                }
            }, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("saveusers", cmd => SaveAllUsers(), AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("savealldata|savedata", cmd =>
            {
                CitizenFX.Core.Native.API.ExecuteCommand("saveusers");
                CitizenFX.Core.Native.API.ExecuteCommand("savevehicles");
                CitizenFX.Core.Native.API.ExecuteCommand("saveproperties");
            }, AdminLevel.SuperAdmin);
            //loadPrivellagedUsers();
        }
Esempio n. 15
0
 public PropertyManager(Server server) : base(server)
 {
     CommandRegister.RegisterRCONCommand("listproperties", cmd =>
     {
         foreach (var property in properties)
         {
             Log.Info("-------------------------------------------------------");
             Log.Info(property.ToString());
             Log.Info("-------------------------------------------------------");
         }
     });
     CommandRegister.RegisterRCONCommand("saveproperties", cmd =>
     {
         saveAllProperties();
     });
     loadPropertyIds();
 }
Esempio n. 16
0
 static void Main(string[] args)
 {
     try
     {
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.WriteLine(" SYNX SERVER (c) craftersmine 2018");
         Console.ResetColor();
         StaticData.ServerRoot     = Environment.CurrentDirectory;
         StaticData.LogsPath       = Path.Combine(StaticData.ServerRoot, "logs");
         StaticData.LoggerInstance = new Utils.Logger("synx-server");
         Log("info", "Initiating Synx server...");
         ServerEnvironment.InitiateEnvironment(StaticData.ServerRoot);
         ServerConfig.LoadConfig();
         StaticData.UserStorage   = new UserStorage();
         StaticData.CommandParser = new CommandParser();
         CommandRegister.RegisterCommands();
         string serverIp = ServerConfig.GetString("bind-ip");
         if (serverIp != string.Empty && serverIp != null && serverIp != "")
         {
             if (IPAddress.TryParse(serverIp, out IPAddress address))
             {
                 ServerController.CreateServerInstance(address, ServerConfig.GetInt("port"));
             }
             else
             {
                 throw new ArgumentException("The IP address for the binding has an invalid format! Check the server configuration!");
             }
         }
         else
         {
             ServerController.CreateServerInstance(IPAddress.Any, ServerConfig.GetInt("port"));
         }
         ServerController.StartServer();
         while (StaticData.IsServerRunning)
         {
             string inp = Console.ReadLine();
             StaticData.CommandParser.ParseInput(inp);
         }
         Log("info", "Synx server was stopped!");
     }
     catch (Exception ex)
     {
         CrashHandler.HandleException(ex);
     }
 }
Esempio n. 17
0
        public void DoesNotRemoveCommandsForTermsMatchingNewTermWhenTermChanges()
        {
            // Arrange
            const long term    = 2L;
            const long logIdx  = 3L;
            var        command = new TestCommand();

            var commandRegister = new CommandRegister();

            commandRegister.Add(term, logIdx, command);
            commandRegister.Get(term, logIdx).Should().Be(command);

            // Act
            commandRegister.Handle(new TermChanged(term));

            // Assert
            commandRegister.Get(term, logIdx).Should().Be(command);
        }
Esempio n. 18
0
        public void RemovesCommandsForOlderTermsWhenTermChanges()
        {
            // Arrange
            const long term    = 1L;
            const long logIdx  = 3L;
            var        command = new TestCommand();

            var commandRegister = new CommandRegister();

            commandRegister.Add(term, logIdx, command);
            commandRegister.Get(term, logIdx).Should().Be(command);

            // Act
            commandRegister.Handle(new TermChanged(term + 1));

            // Assert
            commandRegister.Get(term, logIdx).Should().BeNull();
        }
Esempio n. 19
0
        public Command InterpretRequest(string command)
        {
            Command interpretation;

            if (command.Equals(TextCommands.REGISTER, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandRegister();
            }
            else if (command.Equals(TextCommands.LOGIN, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandLogin();
            }
            else if (command.Equals(TextCommands.LOGOUT, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandLogOut();
            }
            else if (command.Equals(TextCommands.JOINMATCH, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandJoin();
            }
            else if (command.Equals(TextCommands.SELECTCHARACTER, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandSelect();
            }
            else if (command.Equals(TextCommands.MOVE, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandMove();
            }
            else if (command.Equals(TextCommands.ATTACK, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandAttack();
            }
            else if (command.Equals(TextCommands.EXIT, StringComparison.InvariantCultureIgnoreCase))
            {
                interpretation = new CommandExit();
            }
            else
            {
                interpretation = new CommandUnknown();
            }
            return(interpretation);
        }
        public UIEvents(Server server) : base(server)
        {
            CommandRegister.RegisterCommand("setmenulocation", async cmd =>
            {
                var menuLocationName = cmd.GetArgAs(0, "topright");

                if (interactionMenuLocations.ContainsKey(menuLocationName))
                {
                    var playerSettings = cmd.Session./*GetPlayerSettings()*/ PlayerSettings;
                    var menuLocation   = interactionMenuLocations[menuLocationName];

                    playerSettings["Interaction.Menu.X"] = menuLocation.Item1;
                    playerSettings["Interaction.Menu.Y"] = menuLocation.Item2;
                    cmd.Session./*SetPlayerSettings()*/ PlayerSettings = playerSettings;

                    cmd.Session.TriggerEvent("UI.UpdateInteractionMenuLocation", playerSettings["Interaction.Menu.X"], playerSettings["Interaction.Menu.Y"]);
                    Log.ToClient("[Info]", $"Set interacion menu location to {menuLocationName}", ConstantColours.Info, cmd.Player);
                }
            });
        }
Esempio n. 21
0
        public VehicleHandler(Client client) : base(client)
        {
            client.RegisterEventHandler("Vehicle.SetBoughtVehID", new Action <int>(SetBoughtVehId));
            client.RegisterEventHandler("Vehicle.SpawnGarageVehicle", new Action <string, int, string>(OnSpawnRequest));
            client.RegisterEventHandler("Vehicle.ReceiveExternalVehID", new Action <int>(SetVehicleVehId));
            client.RegisterTickHandler(SaveVehicleTick);
            EntityDecoration.RegisterProperty("Vehicle.ID", DecorationType.Int);

            /*CommandRegister.RegisterCommand("testadd", cmd =>
             * {
             *  var closeVeh = GTAHelpers.GetClosestVehicle();
             *  Magicallity.Client.Client.Instance.TriggerServerEvent("Vehicle.CreateExternalVehicle", VehicleDataPacker.PackVehicleData(closeVeh));
             * });
             * CommandRegister.RegisterCommand("getvehid", cmd =>
             * {
             *  Log.ToChat(GTAHelpers.GetClosestVehicle().GetDecor<int>("Vehicle.ID").ToString());
             * });*/
            CommandRegister.RegisterCommand("givekeys", OnGiveKeysCommand);
            CommandRegister.RegisterCommand("giveveh|givevehicle", OnGiveVehCommand);
        }
 public SharedEmergencyItems()
 {
     CommandRegister.RegisterJobCommand("duty", OnDutyRequest, JobType.Police | JobType.EMS | JobType.Mechanic, true);
     CommandRegister.RegisterCommand("911", on911Command);
     CommandRegister.RegisterJobCommand("911r", on911Reply, JobType.Police | JobType.EMS);
     CommandRegister.RegisterCommand("311", on311Command);
     CommandRegister.RegisterJobCommand("311r", on311Reply, JobType.Police | JobType.EMS);
     CommandRegister.RegisterJobCommand("cv", cmd => cmd.Player.TriggerEvent("Job.SpawnServiceVehicle", cmd.GetArgAs(0, 1) - 1), JobType.Police | JobType.EMS);
     CommandRegister.RegisterJobCommand("impound", cmd => cmd.Player.TriggerEvent("Job.DeleteVehicle", true), JobType.Police | JobType.EMS | JobType.Mechanic | JobType.Tow);
     CommandRegister.RegisterJobCommand("fix", cmd => cmd.Player.TriggerEvent("Job.FixVehicle"), JobType.Police | JobType.EMS | JobType.Mechanic);
     CommandRegister.RegisterJobCommand("dv", cmd => cmd.Player.TriggerEvent("Job.DeleteVehicle"), JobType.Police | JobType.EMS);
     CommandRegister.RegisterAdminCommand("dv", cmd => cmd.Player.TriggerEvent("Job.DeleteVehicle"), AdminLevel.Moderator);
     CommandRegister.RegisterJobCommand("13", OnPanicButton, JobType.Police | JobType.EMS);
     CommandRegister.RegisterJobCommand("slimjim", cmd => cmd.Player.TriggerEvent("Lockpick.StartVehicleLockpick", 2), JobType.EMS | JobType.Police | JobType.Mechanic);
     CommandRegister.RegisterJobCommand("extra", cmd => cmd.Player.TriggerEvent("Job.SetVehicleExtra", cmd.GetArgAs(0, "1"), cmd.GetArgAs(1, "false")), JobType.Police | JobType.EMS);
     CommandRegister.RegisterJobCommand("setspawn", OnSetSpawn, JobType.EMS | JobType.Police, true);
     CommandRegister.RegisterJobCommand("resetspawn", OnResetSpawn, JobType.EMS | JobType.Police, true);
     CommandRegister.RegisterJobCommand("discount", cmd => cmd.Player.TriggerEvent("LSC:magicmechanic"), JobType.Mechanic);
     CommandRegister.RegisterJobCommand("setcallsign", OnSetCallsign, JobType.Police | JobType.EMS);
 }
Esempio n. 23
0
        public OutfitHandler(Server server) : base(server)
        {
            CommandRegister.RegisterCommand("saveoutfit", cmd =>
            {
                var outfitName     = string.Join(" ", cmd.Args);
                var playerSession  = cmd.Session;
                var playerSettings = playerSession.GetGlobalData("Character.Settings", "") == "" ? new Dictionary <string, dynamic>() : JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(playerSession.GetGlobalData("Character.Settings", ""));
                var currentOutfits = GetPlayerOutfits(playerSession);

                if (!currentOutfits.ContainsKey(outfitName))
                {
                    currentOutfits[outfitName] = playerSession.GetGlobalData <string>("Character.SkinData");
                    playerSettings["Outfits"]  = currentOutfits;

                    playerSession.SetGlobalData("Character.Settings", JsonConvert.SerializeObject(playerSettings));
                }
                else
                {
                    Log.ToClient("[Info]", $"An outfit with the name ^2{outfitName}^0 already exists", ConstantColours.Info, cmd.Player);
                }
            });

            CommandRegister.RegisterCommand("removeoutfit|deleteoutfit|deloutfit", cmd =>
            {
                var playerSession  = cmd.Session;
                var outfitName     = string.Join(" ", cmd.Args);
                var playerSettings = playerSession.GetGlobalData("Character.Settings", "") == "" ? new Dictionary <string, dynamic>() : JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(playerSession.GetGlobalData("Character.Settings", ""));
                var currentOutfits = GetPlayerOutfits(cmd.Session);

                if (currentOutfits.ContainsKey(outfitName))
                {
                    currentOutfits.Remove(outfitName);
                    playerSettings["Outfits"] = currentOutfits;

                    playerSession.SetGlobalData("Character.Settings", JsonConvert.SerializeObject(playerSettings));
                    Log.ToClient("[Info]", $"Deleted outfit ^2{outfitName}^0", ConstantColours.Info, cmd.Player);
                }
            });

            Server.RegisterEventHandler("Outfit.AttemptChange", new Action <Player, string>(OnChangeOutfit));
        }
Esempio n. 24
0
        public Taxi()
        {
            returnVehicleItem = new MenuItemStandard
            {
                Title      = "Return Job Vehicle",
                OnActivate = async item =>
                {
                    if (Game.PlayerPed.Position.DistanceToSquared(vehicleSpawnLocation) < 200.0f && JobVehicle != null && (JobVehicle.Position.DistanceToSquared(vehicleSpawnLocation) < 200.0f || JobVehicle.IsDead))
                    {
                        if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle == JobVehicle)
                        {
                            Game.PlayerPed.Task.LeaveVehicle(JobVehicle, true);
                        }

                        Log.ToChat("[Job]", "Returning job vehicle", ConstantColours.Job);

                        await BaseScript.Delay(3000);

                        EndJob();
                        Client.Get <InteractionUI>().RemoveInteractionMenuItem(returnVehicleItem);
                    }
                }
            };
            CommandRegister.RegisterCommand("canceltaxijob", new Action <Command>(cmd =>
            {
                if (inTaxiJob)
                {
                    Log.ToChat("[Job]", "You cancelled your current taxi job", ConstantColours.Job);
                    endTaxiJob();
                }
                else
                {
                    Log.ToChat("[Job]", "You must have a fare to cancel your job", ConstantColours.Job);
                }
            }));
            Client.RegisterEventHandler("Player.CheckForInteraction", new Action(OnInteraction));
            LoadBlips();
            //Client.Instance.RegisterTickHandler(JobTick);
            //Client.Instance.RegisterTickHandler(taxiSearchTick);
        }
Esempio n. 25
0
        public Tow()
        {
            returnVehicleItem = new MenuItemStandard
            {
                Title      = "Return Job Vehicle",
                OnActivate = async item =>
                {
                    if (Game.PlayerPed.Position.DistanceToSquared(towDropoffPoint) < 200.0f && currentTowTruck != null && (currentTowTruck.Position.DistanceToSquared(towDropoffPoint) < 200.0f || currentTowTruck.IsDead))
                    {
                        if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle == currentTowTruck)
                        {
                            Game.PlayerPed.Task.LeaveVehicle(currentTowTruck, true);
                        }

                        Log.ToChat("[Job]", "Returning job vehicle", ConstantColours.Job);

                        await BaseScript.Delay(3000);

                        EndJob();
                        Client.Get <InteractionUI>().RemoveInteractionMenuItem(returnVehicleItem);
                    }
                }
            };
            Client.RegisterTickHandler(VehicleGetTick);
            Client.RegisterTickHandler(JobTick);
            Client.RegisterEventHandler("Player.CheckForInteraction", new Action(OnInteraction));
            Client.RegisterEventHandler("Job.GetTowRequest", new Action(OnTowRequest));
            CommandRegister.RegisterCommand("tow", handleTowCommand);
            CommandRegister.RegisterCommand("canceltowjob", handleTowJobCancel);

            BlipHandler.AddBlip("Tow yard", towMarkerLocation, new BlipOptions
            {
                Sprite = BlipSprite.TowTruck
            });

            MarkerHandler.AddMarker(towMarkerLocation, new MarkerOptions
            {
                ScaleFloat = 4.0f
            });
        }
Esempio n. 26
0
        public void TestCommandRegister1()
        {
            // data
            Command command = new Command();
            CommandRegister <ICallTester, int> cr = new CommandRegister <ICallTester, int>(

                command,
                (caller, arg1) => caller.Function2(arg1));
            ICallTester callTester = Substitute.For <ICallTester>();

            // test
            cr.Register(0, callTester);
            command.Run(
                "0Function2",
                new[]
            {
                "1"
            });

            // verify
            cr.Unregister(0);
        }
Esempio n. 27
0
            void InitializeProperties()
            {
                SelectedTrim.Subscribe((v) => {
                    SetTrimSettingsWith(v);
                });
                Prologue.Subscribe((v) => {
                    UpdateButtonStatus();
                });
                Epilogue.Subscribe((v) => {
                    UpdateButtonStatus();
                });
                PrologueEnabled.Subscribe((v) => {
                    UpdateButtonStatus();
                });
                EpilogueEnabled.Subscribe((v) => {
                    UpdateButtonStatus();
                });
                TrimmingName.Subscribe((v) => {
                    UpdateButtonStatus();
                });
                Started.Subscribe((V) => {
                    UpdatePlayingState();
                });
                Pausing.Subscribe((v) => {
                    UpdatePlayingState();
                });
                Duration.Subscribe((v) => {
                });

                CommandRegister.Subscribe(ExecRegister);
                CommandApply.Subscribe(ExecApply);
                CommandUpdate.Subscribe(ExecUpdate);
                CommandUndo.Subscribe(ExecUndo);
                CommandCancel.Subscribe(ExecCancel);
                CommandSelect.Subscribe(ExecSelect);

                Rating.Subscribe(ChangeRating);
            }
Esempio n. 28
0
        public Admin(Server server) : base(server)
        {
            CommandRegister.RegisterAdminCommand("setadminlevel", SetPermissionLevel, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("kick", KickPlayer, AdminLevel.Moderator);
            CommandRegister.RegisterAdminCommand("bring", OnBringCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("return", OnReturnCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("mute", OnMuteCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("unmute", OnUnMuteCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("freeze", OnFreezeCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("unfreeze", OnUnFreezeCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("announce", OnAnnounceCommand, AdminLevel.Admin);
            CommandRegister.RegisterAdminCommand("say", OnSayCommand, AdminLevel.SuperAdmin);
            CommandRegister.RegisterAdminCommand("playerlist", OnPlayerlistCommand, AdminLevel.Moderator);
            CommandRegister.RegisterAdminCommand("sc", OnStaffChatCommand, AdminLevel.Moderator);

            CommandRegister.RegisterRCONCommand("kickall", cmd =>
            {
                foreach (var player in /*Server.PlayerList.ToList()*/ Players.ToList())
                {
                    player.Drop(string.Join(" ", cmd.Args));
                }
            });
        }
Esempio n. 29
0
        public FuelManager(Client client) : base(client)
        {
            EntityDecoration.RegisterProperty("Vehicle.Fuel", DecorationType.Float);
            client.RegisterEventHandler("baseevents:enteredVehicle", new Action <int, int, string>(async(veh, seat, name) =>
            {
                var vehicle = Cache.PlayerPed.CurrentVehicle;

                vehicleFuel = -1;
                if (vehicle.HasDecor("Vehicle.ID"))
                {
                    client.TriggerServerEvent("Vehicle.RequestFuelLevel", vehicle.GetDecor <int>("Vehicle.ID"));
                }

                await BaseScript.Delay(1000);
                client.RegisterTickHandler(FuelTick);
            }));
            client.RegisterEventHandler("baseevents:leftVehicle", new Action <int, int, string>((veh, seat, name) =>
            {
                vehicleFuel = -1;
                client.DeregisterTickHandler(FuelTick);
            }));
            client.RegisterEventHandler("Vehicle.RecieveFuelLevel", new Action <float>(fuel =>
            {
                Log.Verbose($"Recieved a fuel level of {fuel}%");
                vehicleFuel = fuel;
            }));

            client.RegisterTickHandler(CheckForPumps);

            client.Get <InteractionUI>().RegisterInteractionMenuItem(new MenuItemStandard
            {
                Title      = "Refuel vehicle",
                OnActivate = item => PumpRefuel()
            }, () => isNearFuelPump && !Game.PlayerPed.IsInVehicle(), 500);

            CommandRegister.RegisterCommand("refuel", OnRefuelCommand);
        }
        public HousingManager(Server server) : base(server)
        {
            server.RegisterEventHandler("Player.OnInteraction", new Action <Player>(OnInteraction));
            // server.RegisterEventHandler("Housing.CheckCanStoreVeh", new Action<Player>(OnAttemptStoreVehicle));
            CommandRegister.RegisterCommand("showhouse|showhouses", OnShowHouse);
            RegisterHousingCommand("enter", OnHouseEnter);
            RegisterHousingCommand("exit", OnHouseExit);
            RegisterHousingCommand("allow", OnAllowEntry);
            RegisterHousingCommand("disallow", OnDisallowEntry);
            RegisterHousingCommand("buy", OnBuyCommand);
            RegisterHousingCommand("sell", OnSellCommand);

            CommandRegister.RegisterCommand("house", cmd =>
            {
                var cmdName = cmd.GetArgAs(0, "");

                if (housingCommands.ContainsKey(cmdName))
                {
                    cmd.Args.RemoveAt(0);
                    housingCommands[cmdName](cmd);
                }
            });
            loadHouseOwners();
        }
Esempio n. 31
0
 public MiscEvents(Client client) : base(client)
 {
     client.RegisterEventHandler("Player.UpdateLocation", new Action(OnUpdateLocation));
     client.RegisterEventHandler("Player.UpdatePosition", new Action(OnUpdatePosition));
     client.RegisterEventHandler("Player.OnLoginComplete", new Action(() =>
     {
         BaseScript.TriggerEvent("chat:addTemplate", "tweet", "<img src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxz%0D%0AdmcKICB2aWV3Ym94PSIwIDAgMjAwMCAxNjI1LjM2IgogIHdpZHRoPSIyMDAwIgogIGhlaWdodD0i%0D%0AMTYyNS4zNiIKICB2ZXJzaW9uPSIxLjEiCiAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAv%0D%0Ac3ZnIj4KICA8cGF0aAogICAgZD0ibSAxOTk5Ljk5OTksMTkyLjQgYyAtNzMuNTgsMzIuNjQgLTE1%0D%0AMi42Nyw1NC42OSAtMjM1LjY2LDY0LjYxIDg0LjcsLTUwLjc4IDE0OS43NywtMTMxLjE5IDE4MC40%0D%0AMSwtMjI3LjAxIC03OS4yOSw0Ny4wMyAtMTY3LjEsODEuMTcgLTI2MC41Nyw5OS41NyBDIDE2MDku%0D%0AMzM5OSw0OS44MiAxNTAyLjY5OTksMCAxMzg0LjY3OTksMCBjIC0yMjYuNiwwIC00MTAuMzI4LDE4%0D%0AMy43MSAtNDEwLjMyOCw0MTAuMzEgMCwzMi4xNiAzLjYyOCw2My40OCAxMC42MjUsOTMuNTEgLTM0%0D%0AMS4wMTYsLTE3LjExIC02NDMuMzY4LC0xODAuNDcgLTg0NS43MzksLTQyOC43MiAtMzUuMzI0LDYw%0D%0ALjYgLTU1LjU1ODMsMTMxLjA5IC01NS41NTgzLDIwNi4yOSAwLDE0Mi4zNiA3Mi40MzczLDI2Ny45%0D%0ANSAxODIuNTQzMywzNDEuNTMgLTY3LjI2MiwtMi4xMyAtMTMwLjUzNSwtMjAuNTkgLTE4NS44NTE5%0D%0ALC01MS4zMiAtMC4wMzksMS43MSAtMC4wMzksMy40MiAtMC4wMzksNS4xNiAwLDE5OC44MDMgMTQx%0D%0ALjQ0MSwzNjQuNjM1IDMyOS4xNDUsNDAyLjM0MiAtMzQuNDI2LDkuMzc1IC03MC42NzYsMTQuMzk1%0D%0AIC0xMDguMDk4LDE0LjM5NSAtMjYuNDQxLDAgLTUyLjE0NSwtMi41NzggLTc3LjIwMywtNy4zNjQg%0D%0ANTIuMjE1LDE2My4wMDggMjAzLjc1LDI4MS42NDkgMzgzLjMwNCwyODQuOTQ2IC0xNDAuNDI5LDEx%0D%0AMC4wNjIgLTMxNy4zNTEsMTc1LjY2IC01MDkuNTk3MiwxNzUuNjYgLTMzLjEyMTEsMCAtNjUuNzg1%0D%0AMSwtMS45NDkgLTk3Ljg4MjgsLTUuNzM4IDE4MS41ODYsMTE2LjQxNzYgMzk3LjI3LDE4NC4zNTkg%0D%0ANjI4Ljk4OCwxODQuMzU5IDc1NC43MzIsMCAxMTY3LjQ2MiwtNjI1LjIzOCAxMTY3LjQ2MiwtMTE2%0D%0ANy40NyAwLC0xNy43OSAtMC40MSwtMzUuNDggLTEuMiwtNTMuMDggODAuMTc5OSwtNTcuODYgMTQ5%0D%0ALjczOTksLTEzMC4xMiAyMDQuNzQ5OSwtMjEyLjQxIgogICAgc3R5bGU9ImZpbGw6IzAwYWNlZCIv%0D%0APgo8L3N2Zz4K' height='16'> <b style='color:#00BFFF'>{0}</b>: {1}");
         BaseScript.TriggerEvent("chat:addTemplate", "chop", "<div style='background-color: rgba(66, 244, 179, 0.7); border-radius: 10px; width: 100%; text-align: center; vertical-align: middle;'><p style='opacity: 1.0; color: rgb(255, 255, 255);'>{0}</p><p style='text-size: 12px; text-align: right; padding-right: 5px;'>Time remaining: {1}</p></div>");
     }));
     client.RegisterEventHandler("Player.ExecuteCommand", new Action <string>(ExecuteCommand));
     client.RegisterEventHandler("Player.SetPosition", new Action <Vector3>(SetPosition));
     client.RegisterEventHandler("Player.PlayTextAnim", new Action(() => textAnim.PlayFullAnim()));
     client.RegisterEventHandler("Player.PlayRadioAnim", new Action(() => callAnim.PlayFullAnim()));
     client.RegisterEventHandler("Player.SetHeading", new Action <float>(heading => Game.PlayerPed.Heading = heading));
     client.RegisterEventHandler("Player.DoSmoke", new Action(() => EmoteManager.playerAnimations["smoke"].PlayFullAnim()));
     client.RegisterEventHandler("Player.DoDrink", new Action(() => EmoteManager.playerAnimations["drink"].PlayFullAnim()));
     client.RegisterEventHandler("Player.DoDrunkEffect", new Action <string>(OnDoDrunk));
     client.RegisterEventHandler("Vehicle.WashVehicle", new Action(() => Cache.PlayerPed.CurrentVehicle.DirtLevel = 0.0f));
     CommandRegister.RegisterCommand("givecash", OnGiveCash);
     CommandRegister.RegisterCommand("dirt", cmd =>
     {
         Cache.PlayerPed.CurrentVehicle.DirtLevel = 15.0f;
     });
 }
Esempio n. 32
0
        public void TestCommandRegister0()
        {
            var callTester = Substitute.For<ICallTester>();

            var command = new Command();
            var cr = new CommandRegister<ICallTester>(command, caller => caller.Function1());

            cr.Register(callTester);
            command.Run("Function1", new string[0]);
            callTester.Received(1).Function1();
            cr.Unregister();
        }
Esempio n. 33
0
        public void TestCommandRegister1()
        {
            // data
            var command = new Command();
            var cr = new CommandRegister<ICallTester, int>(

                command,
                (caller, arg1) => caller.Function2(arg1));
            var callTester = Substitute.For<ICallTester>();

            // test
            cr.Register(callTester);
            command.Run(
                "Function2",
                new[]
                {
                    "1"
                });

            // verify
            cr.Unregister();
        }