public static void Exec() { try { if (GameManager.Instance.World.Players.dict.Count > 0) { List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null && _cInfoList.Count > 0) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null && _cInfo.playerId != null) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { if (SpectatorEnabled && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Spectator_Admin_Level) { if (_player.IsSpectator) { string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, using spectator mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, using spectator mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); ChatHook.ChatMessage(null, "[FF0000]" + "Cheater! " + _cInfo.playerName + " detected using spectator mode!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for spectator mode\"", _cInfo.playerId), null); string _message = "[FF0000]{PlayerName} has been banned for spectator mode."; _message = _message.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); continue; } } if (GodEnabled && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Godmode_Admin_Level) { if (_player.Buffs.HasBuff("god")) { ChatHook.ChatMessage(null, "[FF0000]" + "Cheater! " + _cInfo.playerName + " detected using god mode!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for god mode\"", _cInfo.playerId), null); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, using god mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, using god mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); string _message = "[FF0000]{PlayerName} has been banned for god mode."; _message = _message.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); continue; } } if (FlyEnabled && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Flying_Admin_Level) { if (_player.IsSpawned() && _player.IsAlive() && !_player.IsStuck && _player.AttachedToEntity == null) { if ((!_player.onGround && AirCheck(_player.position.x, _player.position.y, _player.position.z)) || GroundCheck(_player.position.x, _player.position.y, _player.position.z)) { if (OldY.ContainsKey(_cInfo.entityId)) { OldY.TryGetValue(_cInfo.entityId, out float lastY); OldY[_cInfo.entityId] = _player.position.y; if (lastY - _player.position.y >= 4) { if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } continue; } } else { OldY.Add(_cInfo.entityId, _player.position.y); } if (Flag.TryGetValue(_cInfo.entityId, out int _flags)) { if (_flags + 1 >= Flying_Flags) { Flag.Remove(_cInfo.entityId); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } ChatHook.ChatMessage(null, "[FF0000]" + "Cheater! Player " + _cInfo.playerName + " detected flying!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, flying @ {2} {3} {4}. Steam Id has been banned", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for flying\"", _cInfo.playerId), null); string _message = "[FF0000]{PlayerName} has been banned for flying."; _message = _message.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); continue; } else { Flag[_cInfo.entityId] = _flags + 1; } } else { Flag.Add(_cInfo.entityId, 1); } } else if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } else { if (OldY.ContainsKey(_cInfo.entityId)) { OldY.Remove(_cInfo.entityId); } if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PlayerChecks.Exec: {0}", e.Message)); } }
public static bool ProcessPlayerDamage(EntityAlive __instance, DamageResponse _dmResponse) { try { if (__instance != null) { if (__instance is EntityPlayer) { if (_dmResponse.Source != null && _dmResponse.Strength > 1) { EntityPlayer _player1 = (EntityPlayer)__instance; int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0 && _player1.entityId != _sourceId) { ClientInfo _cInfo2 = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo2 != null) { EntityPlayer _player2 = PersistentOperations.GetEntityPlayer(_cInfo2.playerId); if (_player2 != null) { if (Damage_Detector) { ItemValue _itemValue = ItemClass.GetItem(_dmResponse.Source.ItemClass.GetItemName(), true); if (_itemValue != null) { int _distance = (int)_player2.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} \"{2}\" hit \"{3}\" with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo2.playerId, _cInfo2.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Player_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo2) > Admin_Level) { Phrases.Dict.TryGetValue(952, out string _phrase952); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1} {2}\"", _cInfo2.playerId, _phrase952, _dmResponse.Strength), null); using (StreamWriter sw = new StreamWriter(_detectionFilepath, true)) { sw.WriteLine(string.Format("Detected \"{0}\" Steam Id {1}, exceeded damage limit @ {2}. Damage: {3}", _cInfo2.playerName, _cInfo2.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(951, out string _phrase951); _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo2.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase951 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); return(false); } } } if (Zones.IsEnabled) { if (Zones.ZonePvE.Contains(__instance.entityId) || Zones.ZonePvE.Contains(_cInfo2.entityId)) { Phrases.Dict.TryGetValue(323, out string _phrase323); ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _phrase323 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo2.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo2.entityId, out int _flags); _flags++; if (PersistentOperations.Jail_Violation > 0 && _flags >= PersistentOperations.Jail_Violation) { Jail(_cInfo2, __instance); } if (PersistentOperations.Kill_Violation > 0 && _flags >= PersistentOperations.Kill_Violation) { Kill(_cInfo2); } if (PersistentOperations.Kick_Violation > 0 && _flags >= PersistentOperations.Kick_Violation) { Kick(_cInfo2); } if (PersistentOperations.Ban_Violation > 0 && _flags >= PersistentOperations.Ban_Violation) { Ban(_cInfo2); } } else { PersistentOperations.PvEViolations.Add(_cInfo2.entityId, 1); } } return(false); } } if (Lobby.IsEnabled && Lobby.PvE && Lobby.LobbyPlayers.Contains(__instance.entityId) || Market.IsEnabled && Market.PvE && Market.MarketPlayers.Contains(__instance.entityId)) { Phrases.Dict.TryGetValue(260, out string _phrase260); ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _phrase260 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo2.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo2.entityId, out int _violations); _violations++; if (PersistentOperations.Jail_Violation > 0 && _violations >= PersistentOperations.Jail_Violation) { Jail(_cInfo2, __instance); } if (PersistentOperations.Kill_Violation > 0 && _violations >= PersistentOperations.Kill_Violation) { Kill(_cInfo2); } if (PersistentOperations.Kick_Violation > 0 && _violations >= PersistentOperations.Kick_Violation) { Kick(_cInfo2); } else if (PersistentOperations.Ban_Violation > 0 && _violations >= PersistentOperations.Ban_Violation) { Ban(_cInfo2); } } else { PersistentOperations.PvEViolations.Add(_cInfo2.entityId, 1); } } return(false); } if (KillNotice.IsEnabled) { if (KillNotice.Damage.ContainsKey(_player1.entityId)) { KillNotice.Damage[_player1.entityId] = _dmResponse.Strength; } else { KillNotice.Damage.Add(_player1.entityId, _dmResponse.Strength); } } } } } } } else if (__instance is EntityZombie || __instance is EntityAnimal) { if (_dmResponse.Source != null && _dmResponse.Strength > 1) { int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo != null) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { ItemValue _itemValue = ItemClass.GetItem(_dmResponse.Source.ItemClass.GetItemName(), true); if (_itemValue != null) { if (Damage_Detector) { int _distance = (int)_player.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} \"{2}\" hit \"{3}\" with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Entity_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level) { Phrases.Dict.TryGetValue(952, out string _phrase952); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1} {2}\"", _cInfo.playerId, _phrase952, _dmResponse.Strength), null); using (StreamWriter sw = new StreamWriter(_detectionFilepath, true)) { sw.WriteLine(string.Format("Detected \"{0}\" Steam Id {1}, exceeded damage limit @ {2}. Damage: {3}", _cInfo.playerName, _cInfo.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue(951, out string _phrase951); _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase951 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); return(false); } } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessPlayerDamage: {0}", e.Message)); } return(true); }
public static void Exec() { try { if (GameManager.Instance.World.Players.dict.Count > 0) { List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null && _cInfoList.Count > 0) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null && _cInfo.playerId != null) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { int _userPermissionLevel = GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo); if (SpectatorEnabled && _userPermissionLevel > Spectator_Admin_Level) { if (_player.IsSpectator) { Phrases.Dict.TryGetValue(962, out string _phrase962); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1}\"", _cInfo.playerId, _phrase962), null); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected \"{0}\", Steam id {1}, using spectator mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, using spectator mode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); Phrases.Dict.TryGetValue(961, out string _phrase961); _phrase961 = _phrase961.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase961 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); continue; } } if (GodEnabled && _userPermissionLevel > Godmode_Admin_Level) { if (_player.Buffs.HasBuff("god")) { Phrases.Dict.TryGetValue(972, out string _phrase972); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1}\"", _cInfo.playerId, _phrase972), null); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, using godmode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected \"{0}\", Steam id {1}, using godmode @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); Phrases.Dict.TryGetValue(971, out string _phrase971); _phrase971 = _phrase971.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase971 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); continue; } } if (FlyEnabled && _userPermissionLevel > Flying_Admin_Level) { if (!Teleportation.Teleporting.Contains(_cInfo.entityId) && _player.IsSpawned() && _player.IsAlive() && !_player.IsStuck && !_player.isSwimming && _player.AttachedToEntity == null) { if (OldY.ContainsKey(_cInfo.entityId)) { OldY.TryGetValue(_cInfo.entityId, out float lastY); OldY[_cInfo.entityId] = _player.position.y; if (lastY - _player.position.y >= 4) { if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } continue; } } else { OldY.Add(_cInfo.entityId, _player.position.y); } if (AirCheck(_player.position.x, _player.position.y, _player.position.z) || GroundCheck(_player.position.x, _player.position.y, _player.position.z)) { EntityPlayer _nearbyPlayer = GameManager.Instance.World.GetClosestPlayer(_player, 1f, false); if (_nearbyPlayer != null) { continue; } if (Flag.ContainsKey(_cInfo.entityId)) { Flag.TryGetValue(_cInfo.entityId, out int _flags); _flags++; if (_flags >= Flying_Flags) { Flag.Remove(_cInfo.entityId); Phrases.Dict.TryGetValue(982, out string _phrase982); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1}\"", _cInfo.playerId, _phrase982), null); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, flying @ {2} {3} {4}. Steam Id has been banned", _cInfo.playerName, _cInfo.playerId, (int)_player.position.x, (int)_player.position.y, (int)_player.position.z); Phrases.Dict.TryGetValue(981, out string _phrase981); _phrase981 = _phrase981.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase981 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); continue; } else { Flag[_cInfo.entityId] = _flags; } } else { Flag.Add(_cInfo.entityId, 1); } } else if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } else { if (OldY.ContainsKey(_cInfo.entityId)) { OldY.Remove(_cInfo.entityId); } if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PlayerChecks.Exec: {0}", e.Message)); } }
public static void PlayerStat() { if (ConnectionManager.Instance.ClientCount() > 0) { List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo = ClientInfoList[i]; GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId); AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.IsSpawned()) { var p_speedForward = _player.speedForward; var p_Health = _player.Stats.Health.Value; var p_Stamina = _player.Stats.Stamina.Value; var p_jumpStrength = _player.jumpStrength; var p_height = _player.height; if (p_Health > 250) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} {1} steamId {2} was detected with an illegal health value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_Health)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player {0} steamId {1} with health @ {2}. 250 is maximum", _cInfo.playerName, _cInfo.playerId, p_Health); if (Kick_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and kicked for illegal player stat health" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Auto detection has kicked you for illegal player stat health\"", _cInfo.playerId), (ClientInfo)null); } if (Ban_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and banned for illegal player stat health" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for illegal player stat health\"", _cInfo.playerId), (ClientInfo)null); } } if (p_Stamina > 250) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} {1} steamId {2} was detected with an illegal stamina value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_Stamina)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player {0} steamId {1} with stamina @ {2}. 250 is maximum", _cInfo.playerName, _cInfo.playerId, p_Stamina); if (Kick_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and kicked for illegal player stat stamina" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Auto detection has kicked you for illegal player stat stamina\"", _cInfo.playerId), (ClientInfo)null); } if (Ban_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and banned for illegal player stat stamina" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for illegal player stat stamina\"", _cInfo.playerId), (ClientInfo)null); } } if (p_jumpStrength >= 1.5) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} {1} steamId {2} was detected with an illegal jump strength value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_jumpStrength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player {0} steamId {1} at jump strength {2}. 1.1 is default", _cInfo.playerName, _cInfo.playerId, p_jumpStrength); if (Kick_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and kicked for illegal player jump ability" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Auto detection has kicked you for illegal player stat jump\"", _cInfo.playerId), (ClientInfo)null); } if (Ban_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and banned for illegal player jump ability" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for illegal player stat jump\"", _cInfo.playerId), (ClientInfo)null); } } if (p_height > 1.8 || p_height < 1.7) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} {1} steamId {2} was detected with an illegal player height value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_height)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player {0} steamId {1} with player height @ {2}", _cInfo.playerName, _cInfo.playerId, p_height); if (Kick_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and kicked for illegal player height" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Auto detection has kicked you for illegal player stat height\"", _cInfo.playerId), (ClientInfo)null); } if (Ban_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and banned for illegal player height" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for illegal player stat height\"", _cInfo.playerId), (ClientInfo)null); } } if (p_speedForward > Max_Speed) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} {1} steamId {2} was detected with an illegal run speed value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_speedForward)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player {0} steamId {1} speed hacking", _cInfo.playerName, _cInfo.playerId); if (Kick_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and kicked for illegal player speed" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Auto detection has kicked you for illegal player stat speed\"", _cInfo.playerId), (ClientInfo)null); } if (Ban_Enabled) { ChatHook.ChatMessage(_cInfo, "[FF0000]" + _cInfo.playerName + " was detected and banned for illegal player speed" + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for illegal player stat speed\"", _cInfo.playerId), (ClientInfo)null); } } } } } } }
public static bool ProcessPlayerDamage(EntityAlive __instance, DamageResponse _dmResponse) { try { if (__instance != null && __instance is EntityPlayer && _dmResponse.Source != null) { int _sourceId = _dmResponse.Source.getEntityId(); if (_sourceId > 0) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromEntityId(_sourceId); if (_cInfo != null) { EntityPlayer _player2 = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player2 != null) { if (Damage_Detector) { ItemValue _itemValue = ItemClass.GetItem(_player2.inventory.holdingItem.Name, true); if (_itemValue != null) { int _distance = (int)_player2.GetDistance(__instance); using (StreamWriter sw = new StreamWriter(filepath, true)) { sw.WriteLine(string.Format("{0}: {1} {2} hit {3} with entity id {4} using {5} for {6} damage @ {7}. Distance: {8}", DateTime.Now, _cInfo.playerId, _cInfo.playerName, __instance.EntityName, __instance.entityId, _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(), _dmResponse.Strength, __instance.position, _distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (_dmResponse.Strength >= Entity_Damage_Limit && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level) { string _message = "[FF0000]{PlayerName} has been banned for using damage manipulation."; _message = _message.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"Auto detection has banned you for using damage manipulation. Damage recorded: {1}\"", _cInfo.playerId, _dmResponse.Strength), (ClientInfo)null); using (StreamWriter sw = new StreamWriter(_detectionFilepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, using damage manipulation @ {2}. Damage recorded: {3}", _cInfo.playerName, _cInfo.playerId, __instance.position, _dmResponse.Strength)); sw.WriteLine(); sw.Flush(); sw.Close(); } return(false); } } } if (Zones.IsEnabled) { if (Zones.ZonePvE.Contains(__instance.entityId) || Zones.ZonePvE.Contains(_cInfo.entityId)) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Do not attack players inside a pve zone or while standing in one!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); EntityPlayer _player1 = (EntityPlayer)__instance; if (_player1 != null) { if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo.entityId, out int _flags); _flags++; if (PersistentOperations.Jail_Violation > 0 && _flags >= PersistentOperations.Jail_Violation) { Jail(_cInfo, __instance); } if (PersistentOperations.Kill_Violation > 0 && _flags >= PersistentOperations.Kill_Violation) { Kill(_cInfo); } if (PersistentOperations.Kick_Violation > 0 && _flags >= PersistentOperations.Kick_Violation) { Kick(_cInfo); } if (PersistentOperations.Ban_Violation > 0 && _flags >= PersistentOperations.Ban_Violation) { Ban(_cInfo); } } else { PersistentOperations.PvEViolations.Add(_cInfo.entityId, 1); } } } return(false); } } if (Lobby.IsEnabled && Lobby.PvE && Lobby.LobbyPlayers.Contains(__instance.entityId) || Market.IsEnabled && Market.PvE && Market.MarketPlayers.Contains(__instance.entityId)) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Do not attack players inside the lobby or market!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); EntityPlayer _player1 = (EntityPlayer)__instance; if (_player1 != null) { if (!_player1.IsFriendsWith(_player2)) { if (PersistentOperations.PvEViolations.ContainsKey(_cInfo.entityId)) { PersistentOperations.PvEViolations.TryGetValue(_cInfo.entityId, out int _violations); _violations++; if (PersistentOperations.Jail_Violation > 0 && _violations >= PersistentOperations.Jail_Violation) { Jail(_cInfo, __instance); } if (PersistentOperations.Kill_Violation > 0 && _violations >= PersistentOperations.Kill_Violation) { Kill(_cInfo); } if (PersistentOperations.Kick_Violation > 0 && _violations >= PersistentOperations.Kick_Violation) { Kick(_cInfo); } else if (PersistentOperations.Ban_Violation > 0 && _violations >= PersistentOperations.Ban_Violation) { Ban(_cInfo); } } else { PersistentOperations.PvEViolations.Add(_cInfo.entityId, 1); } } } return(false); } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessPlayerDamage: {0}", e.Message)); } return(true); }
public static void Exec() { try { if (GameManager.Instance.World.Players.dict.Count > 0) { List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); if (ClientInfoList != null && ClientInfoList.Count > 0) { for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo = ClientInfoList[i]; if (_cInfo != null && _cInfo.playerId != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null && _player.IsSpawned()) { var p_speedForward = _player.speedForward; var p_Health = _player.Stats.Health.Value; var p_Stamina = _player.Stats.Stamina.Value; var p_jumpStrength = _player.jumpStrength; var p_height = _player.height; if (p_Health > 250) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} \"{1}\" Steam id {2} was detected with an illegal health value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_Health)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player \"{0}\" Steam id {1} with health @ {2}. 250 is maximum", _cInfo.playerName, _cInfo.playerId, p_Health); if (Kick_Enabled) { Phrases.Dict.TryGetValue(991, out string _phrase991); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase991), null); Phrases.Dict.TryGetValue(992, out string _phrase992); _phrase992 = _phrase992.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase992 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } if (Ban_Enabled) { Phrases.Dict.TryGetValue(993, out string _phrase993); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1}\"", _cInfo.playerId, _phrase993), null); Phrases.Dict.TryGetValue(994, out string _phrase994); _phrase994 = _phrase994.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase994 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } if (p_Stamina > 250) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} \"{1}\" Steam id {2} was detected with an illegal stamina value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_Stamina)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player \"{0}\" Steam id {1} with stamina @ {2}. 250 is maximum", _cInfo.playerName, _cInfo.playerId, p_Stamina); if (Kick_Enabled) { Phrases.Dict.TryGetValue(995, out string _phrase995); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase995), null); Phrases.Dict.TryGetValue(996, out string _phrase996); _phrase996 = _phrase996.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase996 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } if (Ban_Enabled) { Phrases.Dict.TryGetValue(997, out string _phrase997); SdtdConsole.Instance.ExecuteSync(string.Format("ban {0} \"{1}\"", _cInfo.playerId, _phrase997), null); Phrases.Dict.TryGetValue(998, out string _phrase998); _phrase998 = _phrase998.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase998 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } if (p_jumpStrength >= 1.5) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} \"{1}\" Steam id {2} was detected with an illegal jump strength value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_jumpStrength)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player \"{0}\" Steam id {1} at jump strength {2}.", _cInfo.playerName, _cInfo.playerId, p_jumpStrength); if (Kick_Enabled) { Phrases.Dict.TryGetValue(999, out string _phrase999); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase999), null); Phrases.Dict.TryGetValue(1000, out string _phrase1000); _phrase1000 = _phrase1000.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1000 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } if (Ban_Enabled) { Phrases.Dict.TryGetValue(1001, out string _phrase1001); SdtdConsole.Instance.ExecuteSync(string.Format("ban {0} \"{1}\"", _cInfo.playerId, _phrase1001), null); Phrases.Dict.TryGetValue(1002, out string _phrase1002); _phrase1002 = _phrase1002.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1002 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } if (p_height > 1.8 || p_height < 1.7) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} \"{1}\" Steam id {2} was detected with an illegal player height value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_height)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player \"{0}\" Steam id {1} with player height @ {2}", _cInfo.playerName, _cInfo.playerId, p_height); if (Kick_Enabled) { Phrases.Dict.TryGetValue(1003, out string _phrase1003); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase1003), null); Phrases.Dict.TryGetValue(1004, out string _phrase1004); _phrase1004 = _phrase1004.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1004 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } if (Ban_Enabled) { Phrases.Dict.TryGetValue(1005, out string _phrase1005); SdtdConsole.Instance.ExecuteSync(string.Format("ban {0} \"{1}\"", _cInfo.playerId, _phrase1005), null); Phrases.Dict.TryGetValue(1006, out string _phrase1006); _phrase1006 = _phrase1006.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1006 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } if (p_speedForward > Max_Speed) { using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("{0} \"{1}\" Steam id {2} was detected with an illegal run speed value: {3}", DateTime.Now, _cInfo.playerName, _cInfo.playerId, p_speedForward)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("Detected player \"{0}\" Steam id {1} was detected with an illegal run speed", _cInfo.playerName, _cInfo.playerId); if (Kick_Enabled) { Phrases.Dict.TryGetValue(1007, out string _phrase1007); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase1007), null); Phrases.Dict.TryGetValue(1008, out string _phrase1008); _phrase1008 = _phrase1008.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1008 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } if (Ban_Enabled) { Phrases.Dict.TryGetValue(1009, out string _phrase1009); SdtdConsole.Instance.ExecuteSync(string.Format("ban {0} \"{1}\"", _cInfo.playerId, _phrase1009), null); Phrases.Dict.TryGetValue(1010, out string _phrase1010); _phrase1010 = _phrase1010.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase1010 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PlayerStats.Exec: {0}", e.Message)); } }
public static bool ProcessBlockChange(GameManager __instance, string _persistentPlayerId, List <BlockChangeInfo> _blocksToChange) { try { World _world = __instance.World; if (__instance != null && _blocksToChange != null && !string.IsNullOrEmpty(_persistentPlayerId) && _blocksToChange != null) { for (int i = 0; i < _blocksToChange.Count; i++) { BlockChangeInfo _newBlockInfo = _blocksToChange[i]; //new block info BlockValue _oldBlockValue = _world.GetBlock(_newBlockInfo.pos); //old block value Block _oldBlock = _oldBlockValue.Block; if (_newBlockInfo != null && _newBlockInfo.bChangeBlockValue) //new block value { Block _newBlock = _newBlockInfo.blockValue.Block; if (_oldBlockValue.type == BlockValue.Air.type) //old block was air { if (_newBlock is BlockSleepingBag) //placed a sleeping bag { if (POIProtection.IsEnabled && POIProtection.Bed && _world.IsPositionWithinPOI(_newBlockInfo.pos.ToVector3(), 5)) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { GameManager.Instance.World.SetBlockRPC(_newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(_cInfo, _newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue(1031, out string _phrase1031); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1031 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } } else if (_newBlock is BlockLandClaim)//placed a land claim { if (POIProtection.IsEnabled && POIProtection.Claim && _world.IsPositionWithinPOI(_newBlockInfo.pos.ToVector3(), 5)) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { GameManager.Instance.World.SetBlockRPC(_newBlockInfo.pos, BlockValue.Air); PersistentOperations.ReturnBlock(_cInfo, _newBlock.GetBlockName(), 1); Phrases.Dict.TryGetValue(1032, out string _phrase1032); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1032 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(false); } } } else if (_newBlock is BlockPowered)//placed a electric block { Log.Out(string.Format("[SERVERTOOLS] New block is a powered block named {0}", _newBlock.GetBlockName())); } if (BlockLogger.IsEnabled)//placed block { BlockLogger.Log(_persistentPlayerId, _newBlockInfo); } return(true); } if (Damage_Detector) { if (_newBlockInfo.blockValue.type == BlockValue.Air.type) //new block is air { if (_oldBlockValue.type == BlockValue.Air.type) //replaced block { return(true); } if (_oldBlockValue.Block is BlockLandClaim) //removed claim { if (!string.IsNullOrEmpty(_persistentPlayerId)) //id is valid { if (!PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos)) { int _total = _oldBlock.MaxDamage - _oldBlockValue.damage; if (_oldBlock.MaxDamage - _oldBlockValue.damage >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } } if (!_oldBlock.CanPickup && !PersistentOperations.ClaimedByAllyOrSelf(_persistentPlayerId, _newBlockInfo.pos))//old block can not be picked up and unclaimed space { int _total = _oldBlock.MaxDamage - _oldBlockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } else if (_oldBlock.blockID == _newBlock.blockID) //block is the same { if (_newBlockInfo.bChangeDamage) //block took damage { int _total = _newBlockInfo.blockValue.damage - _oldBlockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } if (_oldBlockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0)//block replaced { return(true); } } else if (_oldBlock.DowngradeBlock.Block.blockID == _newBlock.blockID)//downgraded { if (_oldBlockValue.damage == _newBlockInfo.blockValue.damage || _newBlockInfo.blockValue.damage == 0) { return(true); } int _total = _oldBlock.MaxDamage - _oldBlockValue.damage + _newBlockInfo.blockValue.damage; if (_total >= Block_Damage_Limit) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_persistentPlayerId); if (_cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.playerId) > Admin_Level) { BlockPenalty(_total, _persistentPlayerId); return(false); } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.ProcessBlockDamage: {0}", e.Message)); } return(true); }
public static void Exec() { try { if ((int)GameManager.Instance.fps.Counter > 4) { List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0) { AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { EntityAlive _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null && _player.IsSpawned() && _player.IsAlive() && !_player.IsStuck && _player.AttachedToEntity == null) { float _x = _player.position.x; float _y = _player.position.y; float _z = _player.position.z; if (_player.AttachedToEntity == null && (AirCheck(_x, _y, _z) || GroundCheck(_x, _y, _z))) { if (OldY.ContainsKey(_cInfo.entityId)) { float lastY; OldY.TryGetValue(_cInfo.entityId, out lastY); OldY[_cInfo.entityId] = _y; if (lastY - _y >= 4) { if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } continue; } } else { OldY.Add(_cInfo.entityId, _y); } int _flags; if (Flag.TryGetValue(_cInfo.entityId, out _flags)) { if (_flags + 1 >= Flags) { Flag.Remove(_cInfo.entityId); ChatHook.ChatMessage(null, "[FF0000]" + "Cheater! Player " + _cInfo.playerName + " detected flying!" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); Log.Warning("[SERVERTOOLS] Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, _x, _y, _z); string _file = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy")); string _filepath = string.Format("{0}/Logs/DetectionLogs/{1}", API.ConfigPath, _file); using (StreamWriter sw = new StreamWriter(_filepath, true)) { sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, flying @ {2} {3} {4}.", _cInfo.playerName, _cInfo.playerId, _x, _y, _z)); sw.WriteLine(); sw.Flush(); sw.Close(); } Penalty(_cInfo); continue; } else { Flag[_cInfo.entityId] = _flags + 1; } } else { Flag.Add(_cInfo.entityId, 1); } } else if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } else { if (OldY.ContainsKey(_cInfo.entityId)) { OldY.Remove(_cInfo.entityId); } if (Flag.ContainsKey(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Flying.Exec: {0}.", e.Message)); } }
public static bool GameManager_OpenTileEntityAllowed_Prefix(ref bool __result, ref bool __state, int _entityIdThatOpenedIt, TileEntity _te) { try { ClientInfo cInfo = PersistentOperations.GetClientInfoFromEntityId(_entityIdThatOpenedIt); if (cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > 0 && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > 0) { if (DroppedBagProtection.IsEnabled) { if (_te is TileEntityLootContainer) { TileEntityLootContainer lootContainer = _te as TileEntityLootContainer; if (lootContainer.bPlayerBackpack) { if (!DroppedBagProtection.IsAllowed(_entityIdThatOpenedIt, lootContainer)) { Phrases.Dict.TryGetValue("DroppedBagProtection1", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); __result = false; return(false); } } } } if (Shutdown.UI_Locked) { if (_te is TileEntityLootContainer) { TileEntityLootContainer lootContainer = _te as TileEntityLootContainer; if (lootContainer.bPlayerBackpack) { return(true); } } if (_te is TileEntityWorkstation || _te is TileEntityLootContainer || _te is TileEntitySecureLootContainer || _te is TileEntityVendingMachine || _te is TileEntityTrader) { if (_te is TileEntityTrader) { __state = true; } Phrases.Dict.TryGetValue("Shutdown3", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); __result = false; return(false); } } if (WorkstationLock.IsEnabled && _te is TileEntityWorkstation) { EntityPlayer entityPlayer = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (entityPlayer != null) { EnumLandClaimOwner owner = PersistentOperations.ClaimedByWho(cInfo.CrossplatformId, new Vector3i(entityPlayer.position)); if (owner != EnumLandClaimOwner.Self && owner != EnumLandClaimOwner.Ally && !PersistentOperations.ClaimedByNone(new Vector3i(entityPlayer.position))) { Phrases.Dict.TryGetValue("WorkstationLock1", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); __result = false; return(false); } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.GameManager_OpenTileEntityAllowed_Prefix: {0}", e.Message)); } return(true); }