示例#1
0
 public static void Exec(ClientInfo _cInfo)
 {
     if (Reserved_Only && ReservedSlots.IsEnabled && !ReservedSlots.ReservedCheck(_cInfo.PlatformId, _cInfo.CrossplatformId))
     {
         Phrases.Dict.TryGetValue("Lobby9", out string phrase);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         return;
     }
     if (Delay_Between_Uses < 1)
     {
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             CommandCost(_cInfo);
         }
         else
         {
             LobbyTele(_cInfo);
         }
     }
     else
     {
         DateTime lastLobby = DateTime.Now;
         if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastLobby != null)
         {
             lastLobby = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastLobby;
         }
         TimeSpan varTime           = DateTime.Now - lastLobby;
         double   fractionalMinutes = varTime.TotalMinutes;
         int      timepassed        = (int)fractionalMinutes;
         if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
         {
             if (ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString))
             {
                 if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.CombinedString, out DateTime dt))
                 {
                     if (DateTime.Now < dt)
                     {
                         int delay = Delay_Between_Uses / 2;
                         Time(_cInfo, timepassed, delay);
                         return;
                     }
                 }
                 else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out dt))
                 {
                     if (DateTime.Now < dt)
                     {
                         int delay = Delay_Between_Uses / 2;
                         Time(_cInfo, timepassed, delay);
                         return;
                     }
                 }
             }
         }
         Time(_cInfo, timepassed, Delay_Between_Uses);
     }
 }
示例#2
0
 public static void Exec(ClientInfo _cInfo)
 {
     if (Donor_Only && ReservedSlots.IsEnabled && !ReservedSlots.ReservedCheck(_cInfo.playerId))
     {
         Phrases.Dict.TryGetValue(249, out string _phrase249);
         ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase249 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
         return;
     }
     if (Delay_Between_Uses < 1)
     {
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             CommandCost(_cInfo);
         }
         else
         {
             LobbyTele(_cInfo);
         }
     }
     else
     {
         DateTime _lastLobby = DateTime.Now;
         if (PersistentContainer.Instance.Players[_cInfo.playerId].LastLobby != null)
         {
             _lastLobby = PersistentContainer.Instance.Players[_cInfo.playerId].LastLobby;
         }
         TimeSpan varTime           = DateTime.Now - _lastLobby;
         double   fractionalMinutes = varTime.TotalMinutes;
         int      _timepassed       = (int)fractionalMinutes;
         if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
         {
             if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
             {
                 DateTime _dt;
                 ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                 if (DateTime.Now < _dt)
                 {
                     int _delay = Delay_Between_Uses / 2;
                     Time(_cInfo, _timepassed, _delay);
                     return;
                 }
             }
         }
         Time(_cInfo, _timepassed, Delay_Between_Uses);
     }
 }
示例#3
0
 public static void Exec(ClientInfo _cInfo)
 {
     if (Donor_Only && ReservedSlots.IsEnabled && !ReservedSlots.ReservedCheck(_cInfo.playerId))
     {
         ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " this command is locked to donors only" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null);
         return;
     }
     if (Delay_Between_Uses < 1)
     {
         if (Wallet.IsEnabled && Command_Cost >= 1)
         {
             CommandCost(_cInfo);
         }
         else
         {
             MarketTele(_cInfo);
         }
     }
     else
     {
         DateTime _lastMarket       = PersistentContainer.Instance.Players[_cInfo.playerId].LastMarket;
         TimeSpan varTime           = DateTime.Now - _lastMarket;
         double   fractionalMinutes = varTime.TotalMinutes;
         int      _timepassed       = (int)fractionalMinutes;
         if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay)
         {
             if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId))
             {
                 DateTime _dt;
                 ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt);
                 if (DateTime.Now < _dt)
                 {
                     int _delay = Delay_Between_Uses / 2;
                     Time(_cInfo, _timepassed, _delay);
                     return;
                 }
             }
         }
         Time(_cInfo, _timepassed, Delay_Between_Uses);
     }
 }
 public static bool FullServer(string _playerId, string _playerName, string _compatibilityVersion)
 {
     try
     {
         ulong _num;
         if (!Steam.Masterserver.Server.GameServerInitialized || !GameManager.Instance.gameStateManager.IsGameStarted() ||
             GameStats.GetInt(EnumGameStats.GameState) == 2 || string.IsNullOrEmpty(_playerName) ||
             string.IsNullOrEmpty(_playerId) || string.IsNullOrEmpty(_playerId) || !ulong.TryParse(_playerId, out _num) ||
             !string.Equals(Constants.cCompatibilityVersion, _compatibilityVersion, StringComparison.Ordinal))
         {
             return(true);
         }
         List <ClientInfo> list = PersistentOperations.ClientList();
         for (int i = 0; i < list.Count; i++)
         {
             ClientInfo clientInfo = list[i];
             if (clientInfo != null && clientInfo.playerId == _playerId)
             {
                 return(true);
             }
         }
         ClientInfo _cInfoClientToKick = null;
         if (ReservedSlots.AdminCheck(_playerId))
         {
             ClientInfo    _cInfoReservedToKick = null;
             int           _clientSession       = int.MinValue;
             int           _reservedSession     = int.MinValue;
             List <string> _sessionList         = new List <string>(PersistentOperations.Session.Keys);
             if (_sessionList == null)
             {
                 return(true);
             }
             for (int i = 0; i < _sessionList.Count; i++)
             {
                 string     _player = _sessionList[i];
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_player);
                 if (_cInfo2 != null && _playerId != _cInfo2.playerId)
                 {
                     if (ReservedSlots.AdminCheck(_cInfo2.playerId))
                     {
                         continue;
                     }
                     else if (ReservedSlots.ReservedCheck(_cInfo2.playerId))
                     {
                         DateTime _dateTime;
                         if (PersistentOperations.Session.TryGetValue(_cInfo2.playerId, out _dateTime))
                         {
                             TimeSpan varTime           = DateTime.Now - _dateTime;
                             double   fractionalMinutes = varTime.TotalMinutes;
                             int      _timepassed       = (int)fractionalMinutes;
                             if (_timepassed > _reservedSession)
                             {
                                 _reservedSession     = _timepassed;
                                 _cInfoReservedToKick = _cInfo2;
                             }
                         }
                     }
                     else
                     {
                         DateTime _dateTime;
                         if (PersistentOperations.Session.TryGetValue(_cInfo2.playerId, out _dateTime))
                         {
                             TimeSpan varTime           = DateTime.Now - _dateTime;
                             double   fractionalMinutes = varTime.TotalMinutes;
                             int      _timepassed       = (int)fractionalMinutes;
                             if (_timepassed > _clientSession)
                             {
                                 _clientSession     = _timepassed;
                                 _cInfoClientToKick = _cInfo2;
                             }
                         }
                     }
                 }
             }
             if (_cInfoClientToKick != null)
             {
                 API.PlayerDisconnected(_cInfoClientToKick, true);
                 string _phrase20;
                 if (!Phrases.Dict.TryGetValue(20, out _phrase20))
                 {
                     _phrase20 = "{ServerResponseName}- The server is full. You were kicked by the reservation system to open a slot";
                 }
                 _phrase20 = _phrase20.Replace("{ServerResponseName}", LoadConfig.Server_Response_Name);
                 SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfoClientToKick.playerId, _phrase20), (ClientInfo)null);
                 EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfoClientToKick.entityId);
                 if (entityPlayer != null)
                 {
                     if (_cInfoClientToKick.entityId != -1)
                     {
                         Log.Out("Player {0} disconnected after {1} minutes", new object[]
                         {
                             GameUtils.SafeStringFormat(entityPlayer.EntityName),
                             ((Time.timeSinceLevelLoad - entityPlayer.CreationTimeSinceLevelLoad) / 60f).ToCultureInvariantString("0.0")
                         });
                     }
                     entityPlayer.OnEntityUnload();
                 }
                 GC.Collect();
                 MemoryPools.Cleanup();
                 PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_cInfoClientToKick.playerId);
                 if (persistentPlayerData != null)
                 {
                     persistentPlayerData.LastLogin = DateTime.Now;
                     persistentPlayerData.EntityId  = -1;
                 }
                 PersistentOperations.SavePersistentPlayerDataXML();
                 GameManager.Instance.World.aiDirector.RemoveEntity(entityPlayer);
                 GameManager.Instance.World.RemoveEntity(entityPlayer.entityId, EnumRemoveEntityReason.Unloaded);
                 ConnectionManager.Instance.Clients.Remove(_cInfoClientToKick);
                 return(true);
             }
             else if (_cInfoReservedToKick != null)
             {
                 API.PlayerDisconnected(_cInfoReservedToKick, true);
                 string _phrase20;
                 if (!Phrases.Dict.TryGetValue(20, out _phrase20))
                 {
                     _phrase20 = "{ServerResponseName}- The server is full. You were kicked by the reservation system to open a slot";
                 }
                 _phrase20 = _phrase20.Replace("{ServerResponseName}", LoadConfig.Server_Response_Name);
                 SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfoReservedToKick.playerId, _phrase20), (ClientInfo)null);
                 EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfoReservedToKick.entityId);
                 if (entityPlayer != null)
                 {
                     if (_cInfoReservedToKick.entityId != -1)
                     {
                         Log.Out("Player {0} disconnected after {1} minutes", new object[]
                         {
                             GameUtils.SafeStringFormat(entityPlayer.EntityName),
                             ((Time.timeSinceLevelLoad - entityPlayer.CreationTimeSinceLevelLoad) / 60f).ToCultureInvariantString("0.0")
                         });
                     }
                     entityPlayer.OnEntityUnload();
                 }
                 GC.Collect();
                 MemoryPools.Cleanup();
                 PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_cInfoReservedToKick.playerId);
                 if (persistentPlayerData != null)
                 {
                     persistentPlayerData.LastLogin = DateTime.Now;
                     persistentPlayerData.EntityId  = -1;
                 }
                 PersistentOperations.SavePersistentPlayerDataXML();
                 GameManager.Instance.World.aiDirector.RemoveEntity(entityPlayer);
                 GameManager.Instance.World.RemoveEntity(entityPlayer.entityId, EnumRemoveEntityReason.Unloaded);
                 ConnectionManager.Instance.Clients.Remove(_cInfoReservedToKick);
                 return(true);
             }
         }
         else if (ReservedSlots.ReservedCheck(_playerId))
         {
             int           _clientSession = int.MinValue;
             List <string> _sessionList   = new List <string>(PersistentOperations.Session.Keys);
             if (_sessionList == null)
             {
                 return(true);
             }
             for (int i = 0; i < _sessionList.Count; i++)
             {
                 string     _player = _sessionList[i];
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_player);
                 if (_cInfo2 != null && _playerId != _cInfo2.playerId)
                 {
                     if (ReservedSlots.AdminCheck(_cInfo2.playerId))
                     {
                         continue;
                     }
                     else if (ReservedSlots.ReservedCheck(_cInfo2.playerId))
                     {
                         continue;
                     }
                     else
                     {
                         DateTime _dateTime;
                         if (PersistentOperations.Session.TryGetValue(_cInfo2.playerId, out _dateTime))
                         {
                             TimeSpan varTime           = DateTime.Now - _dateTime;
                             double   fractionalMinutes = varTime.TotalMinutes;
                             int      _timepassed       = (int)fractionalMinutes;
                             if (_timepassed > _clientSession)
                             {
                                 _clientSession     = _timepassed;
                                 _cInfoClientToKick = _cInfo2;
                             }
                         }
                     }
                 }
             }
             if (_cInfoClientToKick != null)
             {
                 API.PlayerDisconnected(_cInfoClientToKick, true);
                 string _phrase20;
                 if (!Phrases.Dict.TryGetValue(20, out _phrase20))
                 {
                     _phrase20 = "{ServerResponseName}- The server is full. You were kicked by the reservation system to open a slot";
                 }
                 _phrase20 = _phrase20.Replace("{ServerResponseName}", LoadConfig.Server_Response_Name);
                 SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfoClientToKick.playerId, _phrase20), (ClientInfo)null);
                 EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfoClientToKick.entityId);
                 if (entityPlayer != null)
                 {
                     if (_cInfoClientToKick.entityId != -1)
                     {
                         Log.Out("Player {0} disconnected after {1} minutes", new object[]
                         {
                             GameUtils.SafeStringFormat(entityPlayer.EntityName),
                             ((Time.timeSinceLevelLoad - entityPlayer.CreationTimeSinceLevelLoad) / 60f).ToCultureInvariantString("0.0")
                         });
                     }
                     entityPlayer.OnEntityUnload();
                 }
                 GC.Collect();
                 MemoryPools.Cleanup();
                 PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_cInfoClientToKick.playerId);
                 if (persistentPlayerData != null)
                 {
                     persistentPlayerData.LastLogin = DateTime.Now;
                     persistentPlayerData.EntityId  = -1;
                 }
                 PersistentOperations.SavePersistentPlayerDataXML();
                 GameManager.Instance.World.aiDirector.RemoveEntity(entityPlayer);
                 GameManager.Instance.World.RemoveEntity(entityPlayer.entityId, EnumRemoveEntityReason.Unloaded);
                 ConnectionManager.Instance.Clients.Remove(_cInfoClientToKick);
                 return(true);
             }
         }
         else if (ReservedSlots.Session_Time > 0)
         {
             int           _session     = int.MinValue;
             List <string> _sessionList = new List <string>(PersistentOperations.Session.Keys);
             if (_sessionList == null)
             {
                 return(true);
             }
             for (int i = 0; i < _sessionList.Count; i++)
             {
                 string     _player = _sessionList[i];
                 ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_player);
                 if (_cInfo2 != null && _playerId != _cInfo2.playerId)
                 {
                     if (ReservedSlots.AdminCheck(_cInfo2.playerId))
                     {
                         continue;
                     }
                     else if (ReservedSlots.ReservedCheck(_cInfo2.playerId))
                     {
                         continue;
                     }
                     else
                     {
                         DateTime _dateTime;
                         if (PersistentOperations.Session.TryGetValue(_cInfo2.playerId, out _dateTime))
                         {
                             TimeSpan varTime           = DateTime.Now - _dateTime;
                             double   fractionalMinutes = varTime.TotalMinutes;
                             int      _timepassed       = (int)fractionalMinutes;
                             if (_timepassed >= ReservedSlots.Session_Time && _timepassed > _session)
                             {
                                 _session           = _timepassed;
                                 _cInfoClientToKick = _cInfo2;
                             }
                         }
                     }
                 }
             }
             if (_session > int.MinValue)
             {
                 ReservedSlots.Kicked.Add(_cInfoClientToKick.playerId, DateTime.Now);
                 API.PlayerDisconnected(_cInfoClientToKick, true);
                 string _phrase20;
                 if (!Phrases.Dict.TryGetValue(20, out _phrase20))
                 {
                     _phrase20 = "{ServerResponseName}- The server is full. You were kicked by the reservation system to open a slot";
                 }
                 _phrase20 = _phrase20.Replace("{ServerResponseName}", LoadConfig.Server_Response_Name);
                 SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfoClientToKick.playerId, _phrase20), (ClientInfo)null);
                 EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfoClientToKick.entityId);
                 if (entityPlayer != null)
                 {
                     if (_cInfoClientToKick.entityId != -1)
                     {
                         Log.Out("Player {0} disconnected after {1} minutes", new object[]
                         {
                             GameUtils.SafeStringFormat(entityPlayer.EntityName),
                             ((Time.timeSinceLevelLoad - entityPlayer.CreationTimeSinceLevelLoad) / 60f).ToCultureInvariantString("0.0")
                         });
                     }
                     entityPlayer.OnEntityUnload();
                 }
                 GC.Collect();
                 MemoryPools.Cleanup();
                 PersistentPlayerData persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_cInfoClientToKick.playerId);
                 if (persistentPlayerData != null)
                 {
                     persistentPlayerData.LastLogin = DateTime.Now;
                     persistentPlayerData.EntityId  = -1;
                 }
                 PersistentOperations.SavePersistentPlayerDataXML();
                 GameManager.Instance.World.aiDirector.RemoveEntity(entityPlayer);
                 GameManager.Instance.World.RemoveEntity(entityPlayer.entityId, EnumRemoveEntityReason.Unloaded);
                 ConnectionManager.Instance.Clients.Remove(_cInfoClientToKick);
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in ReservedSlots.FullServer: {0}.", e.Message));
     }
     return(true);
 }