Exemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer UPlayer = (UnturnedPlayer)caller;

            PlayerSession session = PlayerSessionStore.GetPlayerData(UPlayer);

            if (command.Length >= 1)
            {
                if (session.FlySessionActive)
                {
                    UnturnedChat.Say(caller, "SetGravity_Self_Fail_IsFlying".Translate());
                }
                else
                {
                    if (float.TryParse(command[0], out float Val))
                    {
                        UPlayer.Player.movement.sendPluginGravityMultiplier(Val);

                        UnturnedChat.Say(caller, "SetGravity_Self_Pass_GravityChanged".Translate(Val));
                    }
                    else
                    {
                        UnturnedChat.Say(caller, "SetGravity_Self_Fail_InvalidParameter".Translate());
                    }
                }
            }
            else
            {
                UnturnedChat.Say(caller, Syntax);
            }
        }
 public void LoadCurrentPlayers()
 {
     foreach (var client in Provider.clients)
     {
         UnturnedPlayer Player = UnturnedPlayer.FromSteamPlayer(client);
         PlayerDataStore.TryRegisterPlayer(Player);
         PlayerSessionStore.TryRegisterPlayer(Player);
     }
 }
 public void ForEachNonFlyingPlayer(Action <Player> action)
 {
     foreach (SteamPlayer client in Provider.clients)
     {
         PlayerSession session = PlayerSessionStore.GetPlayerData(client.player);
         if (session != null && !session.FlySessionActive)
         {
             action(client.player);
         }
     }
 }
Exemplo n.º 4
0
 public void Execute(IRocketPlayer caller, string[] command)
 {
     if (command.Length > 0)
     {
         UnturnedPlayer TargetPlayer = UnturnedPlayer.FromName(command[0]);
         if (TargetPlayer != null)
         {
             PlayerSession Session = PlayerSessionStore.GetPlayerData(TargetPlayer);
             if (Session == null)
             {
                 return;
             }
             if (Session.FlySessionActive)
             {
                 // Stop Session
                 Session.StartFlightSession();
                 UnturnedChat.Say(caller, "Flight_Disabled_Other".Translate(TargetPlayer.DisplayName));
                 UnturnedChat.Say(TargetPlayer, "Flight_Disabled".Translate());
             }
             else
             {
                 // Start Session
                 Session.StartFlightSession();
                 UnturnedChat.Say(caller, "Flight_Enabled_Other".Translate(TargetPlayer.DisplayName));
                 UnturnedChat.Say(TargetPlayer, "Flight_Enabled".Translate());
             }
         }
         else
         {
             UnturnedChat.Say(caller, "Error_PlayerNotFound".Translate());
         }
     }
     else
     {
         UnturnedPlayer Player  = (UnturnedPlayer)caller;
         PlayerSession  Session = PlayerSessionStore.GetPlayerData(Player);
         if (Session.FlySessionActive)
         {
             // Stop Session
             Session.StopFlightSession();
             UnturnedChat.Say(caller, "Flight_Disabled".Translate());
         }
         else
         {
             // Start Session
             Session.StartFlightSession();
             UnturnedChat.Say(caller, "Flight_Enabled".Translate());
         }
     }
 }
        public override void LoadPlugin()
        {
            Logger.Log($"Loading ShimmysAdminTools v{UpdaterCore.CurrentVersion} by ShimmyMySherbet");
            base.LoadPlugin();
            Instance = this;
            Config   = Configuration.Instance;
            PlayerDataStore.Init();
            PlayerSessionStore.Init();
            U.Events.OnBeforePlayerConnected       += Events_OnBeforePlayerConnected;
            U.Events.OnPlayerConnected             += Events_OnPlayerConnected;
            U.Events.OnPlayerDisconnected          += Events_OnPlayerDisconnected;
            VehicleManager.onEnterVehicleRequested += VehicleManager_onEnterVehicleRequested;
            Rocket.Unturned.Events.UnturnedPlayerEvents.OnPlayerUpdateGesture += UnturnedPlayerEvents_OnPlayerUpdateGesture;

            ChatManager.onCheckPermissions += Chat_OnCheckPermissions;

            LoadCurrentPlayers();

            Level.onLevelLoaded += OnLevelloaded;


            Logger.Log("Checking for updates...");
            UpdaterCore.Init();

            if (UpdaterCore.IsOutDated)
            {
                Logger.LogWarning("ShimmysAdminTools is out of date!");
                Logger.Log($"Latest Version: v{UpdaterCore.LatestVersion}");
                if (UpdaterCore.TryGetUpdateMessage(out string msg))
                {
                    Logger.Log($"Update Notes:");
                    Logger.Log(msg);
                }
                Logger.Log("Download the latest update at https://github.com/ShimmyMySherbet/ShimmysAdminTools");
            }

            gameObject.AddComponent <RepeatCommandQueue>();

            if (!Config.DelayStartEXECUtility)
            {
                ExecManager.Activate();
            }
            Logger.Log("ShimmysAdminTools loaded.");
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (AdminToolsPlugin.Config.DisableAbusableCommands)
            {
                UnturnedChat.Say(caller, "Fail_Command_Disabled".Translate());
                return;
            }
            PlayerSession session = PlayerSessionStore.GetPlayerData((UnturnedPlayer)caller);

            if (session.MapJumpingSession == null)
            {
                session.StartMapJumpingSession();
                UnturnedChat.Say(caller, "MapJump_Enabled".Translate());
            }
            else
            {
                session.StopMapJumpingSession();
                UnturnedChat.Say(caller, "MapJump_Disabled".Translate());
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            PlayerSession Session = PlayerSessionStore.GetPlayerData((UnturnedPlayer)caller);

            if (command.Length == 0)
            {
                if (Session.IsSpyingCommands)
                {
                    Session.DisableCommandSpy();
                    UnturnedChat.Say(caller, "CommandSpy_Disabled".Translate());
                }
                else
                {
                    Session.CommandSpyGlobalEnabled = true;
                    UnturnedChat.Say(caller, "CommandSpy_Enabled_Global".Translate());
                }
            }
            else
            {
                UnturnedPlayer Target = UnturnedPlayer.FromName(command[0]);
                if (Target == null)
                {
                    UnturnedChat.Say(caller, "Error_PlayerNotFound".Translate());
                }
                else
                {
                    ulong PlayerID = Target.CSteamID.m_SteamID;
                    if (Session.CommandSpyPlayers.Contains(PlayerID))
                    {
                        UnturnedChat.Say(caller, "CommandSpy_Disabled_Player".Translate(Target.DisplayName));
                        Session.CommandSpyPlayers.Remove(PlayerID);
                    }
                    else
                    {
                        UnturnedChat.Say(caller, "CommandSpy_Enabled_Player".Translate(Target.DisplayName));
                        Session.CommandSpyPlayers.Add(PlayerID);
                    }
                }
            }
        }
 private void Events_OnPlayerDisconnected(UnturnedPlayer player)
 {
     PlayerSessionStore.TryDeregisterPlayer(player);
 }
 private void Events_OnBeforePlayerConnected(UnturnedPlayer player)
 {
     PlayerSessionStore.TryRegisterPlayer(player);
     PlayerDataStore.TryRegisterPlayer(player);
 }
Exemplo n.º 10
0
 public static PlayerSession GetSession(this UnturnedPlayer Player)
 {
     return(PlayerSessionStore.GetPlayerData(Player));
 }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer Player  = (UnturnedPlayer)caller;
            PlayerSession  Session = PlayerSessionStore.GetPlayerData(Player);

            if (command.Length == 0)
            {
                Session.PointToolEnabled = !Session.PointToolEnabled;
                if (Session.PointToolEnabled)
                {
                    UnturnedChat.Say(caller, "PointTool_EnabledActive".Translate(Session.PointTool));
                    Player.Player.gameObject.AddComponent <PointToolInputListener>();
                }
                else
                {
                    UnturnedChat.Say(caller, "PointTool_Disabled".Translate());
                    Player.Player.gameObject.DestroyComponentIfExists <PointToolInputListener>();
                }
            }
            else
            {
                PointToolMode PrevTool = Session.PointTool;
                bool          SendMsg  = false;
                string        Send     = "";
                string        arg      = command[0].ToLower();
                if (arg == "d" || arg == "destroy")
                {
                    Session.PointTool = PointToolMode.Destroy;
                    SendMsg           = true;
                    Send = "PointTool_Selected_Destroy".Translate();
                }
                else if (arg == "r" || arg == "repair")
                {
                    Session.PointTool = PointToolMode.Repair;
                    SendMsg           = true;
                    Send = "PointTool_Selected_Repair".Translate();
                }
                else if (arg == "u" || arg == "utility")
                {
                    Session.PointTool = PointToolMode.Utility;
                    SendMsg           = true;
                    Send = "PointTool_Selected_Utility".Translate();
                }
                else if (arg == "k" || arg == "kill")
                {
                    Session.PointTool = PointToolMode.Kill;
                    SendMsg           = true;
                    Send = "PointTool_Selected_Kill".Translate();
                }
                else if (arg == "j" || arg == "jump")
                {
                    Session.PointTool = PointToolMode.Jump;
                    SendMsg           = true;
                    Send = "PointTool_Selected_Jump".Translate();
                }
                if (PlayerCanUseMode(Player, Session.PointTool))
                {
                    if (SendMsg)
                    {
                        if (Session.PointToolEnabled)
                        {
                            UnturnedChat.Say(caller, Send);
                        }
                        else
                        {
                            Session.PointToolEnabled = true;
                            UnturnedChat.Say(caller, Send + "PointTool_Extension_Enabled".Translate());
                            Player.Player.gameObject.AddComponent <PointToolInputListener>();
                        }
                    }
                    else
                    {
                        UnturnedChat.Say(caller, "Tools: Destroy, Utility, Jump, Kill");
                    }
                }
                else
                {
                    Session.PointTool = PrevTool;
                    UnturnedChat.Say(caller, "PointTool_Denied".Translate());
                }
            }
        }