public static void PlayerLoginRPC_Prefix(string _playerId, out bool __state)
 {
     __state = false;
     try
     {
         if (_playerId != null && _playerId.Length == 17)
         {
             int __maxPlayers = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount);
             if (ReservedSlots.IsEnabled && ConnectionManager.Instance.ClientCount() > __maxPlayers)
             {
                 if (ReservedSlots.FullServer(_playerId))
                 {
                     GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, __maxPlayers + 1);
                     __state = true;
                     return;
                 }
             }
             if (NewPlayer.IsEnabled && NewPlayer.Block_During_Bloodmoon && SkyManager.BloodMoon())
             {
                 PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerDataFromSteamId(_playerId);
                 if (_ppd == null)
                 {
                     ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_playerId);
                     if (_cInfo != null)
                     {
                         _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerDenied>().Setup(new GameUtils.KickPlayerData(GameUtils.EKickReason.ManualKick, 0, default, "[ServerTools] - New players are kicked during the bloodmoon. Please return after the bloodmoon is over")));
Example #2
0
 public static void PlayerLoginRPC_Postfix(bool __state)
 {
     try
     {
         if (__state)
         {
             int _maxCount = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount);
             GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, _maxCount - 1);
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Injections.PlayerLoginRPC_Postfix: {0}", e.Message));
     }
 }
Example #3
0
 static void Postfix(XUiC_MainMenu __instance)
 {
     if (SphereIIToggleCapsLock.GetScrollLock())
     {
         if (GamePrefs.GetInt(EnumGamePrefs.AutopilotMode) == 0)
         {
             GamePrefs.Set(EnumGamePrefs.AutopilotMode, 1);
             MethodInfo method = __instance.GetType().GetMethod("btnContinueGame_OnPressed", BindingFlags.NonPublic | BindingFlags.Instance);
             method.Invoke(__instance, new object[] { null, null });
         }
         else if (GamePrefs.GetInt(EnumGamePrefs.AutopilotMode) == 1)
         {
             MethodInfo method = __instance.GetType().GetMethod("btnQuit_OnPressed", BindingFlags.NonPublic | BindingFlags.Instance);
             method.Invoke(__instance, new object[] { null, null });
         }
     }
 }
Example #4
0
 public static void PlayerLoginRPC_Prefix(string _playerId, out bool __state)
 {
     __state = false;
     try
     {
         int _maxCount = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount);
         if (ReservedSlots.IsEnabled && _playerId != null && _playerId.Length == 17 && ConnectionManager.Instance.ClientCount() > _maxCount)
         {
             if (ReservedSlots.FullServer(_playerId))
             {
                 GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, _maxCount + 1);
                 __state = true;
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Injections.PlayerLoginRPC_Prefix: {0}", e.Message));
     }
 }
Example #5
0
 public static void PlayerLoginRPC_Prefix(ClientInfo _cInfo, string _playerName, ValueTuple <PlatformUserIdentifierAbs, string> _platformUserAndToken, ValueTuple <PlatformUserIdentifierAbs, string> _crossplatformUserAndToken, out bool __state)
 {
     __state = false;
     try
     {
         if (_platformUserAndToken.Item1 != null && _crossplatformUserAndToken.Item1 != null)
         {
             if (ReservedSlots.IsEnabled)
             {
                 int maxPlayers = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount);
                 if (ConnectionManager.Instance.ClientCount() > maxPlayers && ReservedSlots.FullServer(_cInfo, _platformUserAndToken.Item1, _crossplatformUserAndToken.Item1))
                 {
                     GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, maxPlayers + 1);
                     __state = true;
                     return;
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in Injections.PlayerLoginRPC_Prefix: {0}", e.Message));
     }
 }
Example #6
0
        public bool SetConfig(string confName, string confValue, bool bSave = true, bool setGamePref = false)
        {
            bool wasSet = false;

            switch (confName.ToLower())
            {
            case "tickrate":
                int confTickRate = -1;
                if (int.TryParse(confValue, out confTickRate))
                {
                    tickRate = confTickRate;
                    wasSet   = true;
                }
                break;

            case "worldtype":
                switch (confValue.ToLower())
                {
                case "navezgane":
                    WorldType = "Navezgane";
                    if (setGamePref)
                    {
                        GamePrefs.Set(EnumGamePrefs.GameWorld, WorldType);
                    }
                    wasSet = true;
                    break;

                case "random":
                case "random gen":
                    WorldType = "Random Gen";
                    if (setGamePref)
                    {
                        GamePrefs.Set(EnumGamePrefs.GameWorld, WorldType);
                    }
                    wasSet = true;
                    break;

                default:
                    Log.Warning("[7dtmLib] Invalid World Config Type Value '" + confValue + "'; ignoring.");
                    break;
                }
                break;

            case "worldname":
                WorldName = confValue;
                if (setGamePref)
                {
                    GamePrefs.Set(EnumGamePrefs.GameName, WorldName);
                }
                wasSet = true;
                break;

            case "chatcommandsenabled":
                ChatCommandsEnabled = confValue.ToLower() == "true" ? true : false;
                wasSet = true;
                break;
            }

            if (wasSet)
            {
                if (bSave)
                {
                    SaveConfig();
                }
                return(true);
            }

            return(false);
        }
Example #7
0
 private void ToggleCmDm()
 {
     GameStats.Set(EnumGameStats.ShowSpawnWindow, cmDm);
     GameStats.Set(EnumGameStats.IsCreativeMenuEnabled, cmDm);
     GamePrefs.Set(EnumGamePrefs.DebugMenuEnabled, cmDm);
 }