private static void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile)//Setting player view and profile { try { if (_cInfo != null) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), (ClientInfo)null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned your country or region code\"", _cInfo.playerId), (ClientInfo)null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; PersistentContainer.Instance.Save(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawning: {0}.", e.Message)); } }
public void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { if (_cInfo != null) { if (CountryBan.IsEnabled && _cInfo.ip != "127.0.0.1" && !_cInfo.ip.StartsWith("192.168")) { if (CountryBan.IsCountryBanned(_cInfo)) { return; } } string _sql = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);; DataTable _result = SQL.TQuery(_sql); string _name = SQL.EscapeString(_cInfo.playerName); if (_result.Rows.Count == 0) { _sql = string.Format("INSERT INTO Players (steamid, playername, last_joined) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _name, DateTime.Now); } else { _sql = string.Format("UPDATE Players SET playername = '{0}', last_joined = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _cInfo.playerId); } _result.Dispose(); SQL.FastQuery(_sql); if (StopServer.NoEntry) { int _seconds = (60 - Timers._sSCD); string _phrase452; if (!Phrases.Dict.TryGetValue(452, out _phrase452)) { _phrase452 = "Shutdown is in {Minutes} minutes {Seconds} seconds. Please come back after the server restarts."; } _phrase452 = _phrase452.Replace("{Minutes}", Timers._sSC.ToString()); _phrase452 = _phrase452.Replace("{Seconds}", _seconds.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase452), (ClientInfo)null); } if (ReservedSlots.IsEnabled) { if (ReservedSlots.Kicked.ContainsKey(_cInfo.playerName)) { DateTime _dateTime; ReservedSlots.Kicked.TryGetValue(_cInfo.playerId, out _dateTime); TimeSpan varTime = DateTime.Now - _dateTime; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed >= 5) { int _timeleft = 5 - _timepassed; string _phrase22; if (!Phrases.Dict.TryGetValue(22, out _phrase22)) { _phrase22 = "Sorry {PlayerName} you have reached the max session time. Please wait {TimeRemaining} minutes before rejoining."; } _phrase22 = _phrase22.Replace("{PlayerName}", _cInfo.playerName); _phrase22 = _phrase22.Replace("{TimeRemaining}", _timeleft.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase22), (ClientInfo)null); } else { ReservedSlots.CheckReservedSlot(_cInfo); } } else { ReservedSlots.CheckReservedSlot(_cInfo); } } if (CredentialCheck.IsEnabled) { CredentialCheck.AccCheck(_cInfo); } if (Motd.IsEnabled && !Motd.Show_On_Respawn) { Motd.Send(_cInfo); } if (AutoShutdown.IsEnabled) { if (AutoShutdown.Alert_On_Login) { AutoShutdown.CheckNextShutdown(_cInfo, false); } } if (Bloodmoon.Show_On_Login && !Bloodmoon.Show_On_Respawn) { Bloodmoon.GetBloodmoon(_cInfo, false); } if (LoginNotice.IsEnabled) { LoginNotice.PlayerCheck(_cInfo); } Players.SessionTime(_cInfo); } }
private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player { try { if (_cInfo != null && _cInfo.playerId.Length == 17) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for country IP region\"", _cInfo.playerId), null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawning. Game bug has returning players trigger this on server restarts { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer) { Timers.NewPlayerExecTimer(_cInfo); } else { OldPlayerJoined(_cInfo); } } else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawning { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer) { Timers.NewPlayerExecTimer(_cInfo); } else { OldPlayerJoined(_cInfo); } } else if (_respawnReason == RespawnType.Died)//Player died, respawning { PersistentOperations.SessionTime(_cInfo); PlayerDied(_cInfo); } else if (_respawnReason == RespawnType.Teleport) { if (Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Remove(_cInfo.entityId); } } if (BattleLogger.IsEnabled && !BattleLogger.Exit.Contains(_cInfo.playerId) && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > BattleLogger.Admin_Level) { BattleLogger.Exit.Add(_cInfo.playerId); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}", e.Message)); } }
private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player { try { if (_cInfo != null && _cInfo.playerId != null) { if (CredentialCheck.IsEnabled && !CredentialCheck.AccCheck(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for false credentials. Contact an admin if this is a mistake\"", _cInfo.playerId), null); return; } if (CountryBan.IsEnabled && CountryBan.IsCountryBanned(_cInfo)) { SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 1 years \"Auto detection has banned you for country IP region\"", _cInfo.playerId), null); return; } PersistentContainer.Instance.Players[_cInfo.playerId].LastJoined = DateTime.Now; if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentOperations.SessionTime(_cInfo); if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawning. Game bug can trigger this incorrectly { if (_player.distanceWalked < 1 && _player.totalTimePlayed <= 1) { Timers.NewPlayerTimer(_cInfo); } else { OldPlayerJoined(_cInfo, _player); } } else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawning { if (_player.distanceWalked < 1 && _player.totalTimePlayed <= 10) { Timers.NewPlayerTimer(_cInfo); } else { OldPlayerJoined(_cInfo, _player); } } else if (_respawnReason == RespawnType.Died)//Player died, respawning { PlayerDied(_cInfo); } else if (_respawnReason == RespawnType.Teleport) { if (Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Remove(_cInfo.entityId); } } } if (ExitCommand.IsEnabled && !ExitCommand.Players.ContainsKey(_cInfo.entityId) && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > ExitCommand.Admin_Level) { ExitCommand.Players.Add(_cInfo.entityId, _player.position); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}", e.Message)); } }