public static void NewPlayerExec(ClientInfo _cInfo) { try { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (_player.IsSpawned() && _player.IsAlive()) { if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position != "0,0,0") { NewSpawnTele.TeleNewSpawn(_cInfo, _player); if (StartingItems.IsEnabled && StartingItems.ItemList.Count > 0) { Timers.StartingItemsTimer(_cInfo); } } else if (StartingItems.IsEnabled && StartingItems.ItemList.Count > 0) { StartingItems.Exec(_cInfo); } ProcessPlayer(_cInfo, _player); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec: {0}", e.Message)); } }
//private static void PutPlayerInJail(ClientInfo _cInfo, ClientInfo _PlayertoJail) //{ // string[] cords = Jail_Position.Split(','); // int.TryParse(cords[0], out int x); // int.TryParse(cords[1], out int y); // int.TryParse(cords[2], out int z); // _PlayertoJail.SendPackage(NetPackageManager.GetPackage<NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); // Jailed.Add(_PlayertoJail.CrossplatformId.CombinedString); // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailTime = 60; // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailName= _PlayertoJail.playerName; // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailDate = DateTime.Now; // PersistentContainer.DataChange = true; // Phrases.Dict.TryGetValue("Jail1", out string phrase); // ChatHook.ChatMessage(_PlayertoJail, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); // if (Jail_Shock) // { // Phrases.Dict.TryGetValue("Jail8", out phrase); // ChatHook.ChatMessage(_PlayertoJail, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); // } // Phrases.Dict.TryGetValue("Jail6", out phrase); // phrase = phrase.Replace("{PlayerName}", _PlayertoJail.playerName); // ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); //} public static void StatusCheck() { if (Jailed.Count > 0) { for (int i = 0; i < Jailed.Count; i++) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(Jailed[i]); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player.Spawned && player.IsAlive()) { string[] cords = Jail_Position.Split(','); int.TryParse(cords[0], out int x); int.TryParse(cords[1], out int y); int.TryParse(cords[2], out int z); Vector3 vector = player.position; if ((x - vector.x) * (x - vector.x) + (z - vector.z) * (z - vector.z) >= Jail_Size * Jail_Size) { cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); if (Jail_Shock) { cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup("buff buffShocked", true)); Phrases.Dict.TryGetValue("Jail9", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } }
public static void Check(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (_player.IsAlive()) { int _deaths = XUiM_Player.GetDeaths(_player); if (_deaths < Max_Deaths) { int _lives = Max_Deaths - _deaths; string _phrase950; if (!Phrases.Dict.TryGetValue(950, out _phrase950)) { _phrase950 = "Hardcore: Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Score {Score}, Lives remaining {Lives}..."; } _phrase950 = _phrase950.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase950 = _phrase950.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase950 = _phrase950.Replace("{Score}", _player.Score.ToString()); _phrase950 = _phrase950.Replace("{Lives}", _lives.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase950 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { EndGame(_cInfo, _player); } } } }
public static void NewPlayerExec2(ClientInfo _cInfo) { try { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { if (_player.IsSpawned() && _player.IsAlive()) { if (StartingItems.IsEnabled && StartingItems.ItemList.Count > 0) { StartingItems.Exec(_cInfo); } NewPlayerExec3(_cInfo, _player); } else { Timers.NewPlayerStartingItemsTimer(_cInfo); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec2: {0}", e.Message)); } }
public static void Check(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (_player.IsAlive()) { int _deaths = XUiM_Player.GetDeaths(_player); if (_deaths < Max_Deaths) { int _lives = Max_Deaths - _deaths; string _phrase950; if (!Phrases.Dict.TryGetValue(950, out _phrase950)) { _phrase950 = "Hardcore: Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Score {Score}, Lives remaining {Lives}..."; } _phrase950 = _phrase950.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase950 = _phrase950.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase950 = _phrase950.Replace("{Score}", _player.Score.ToString()); _phrase950 = _phrase950.Replace("{Lives}", _lives.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase950), Config.Server_Response_Name, false, "ServerTools", false)); } else { EndGame(_cInfo, _player); } } } }
public static void NewPlayerExec(ClientInfo _cInfo) { try { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (player.IsSpawned() && player.IsAlive()) { if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position != "0,0,0") { NewSpawnTele.TeleNewSpawn(_cInfo, player); if (StartingItems.IsEnabled && StartingItems.Dict.Count > 0) { Timers.StartingItemsTimer(_cInfo); } } else if (StartingItems.IsEnabled && StartingItems.Dict.Count > 0) { StartingItems.Exec(_cInfo, null); } ProcessPlayer(_cInfo, player); } else { PersistentOperations.NewPlayerQue.Add(_cInfo); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec: {0}", e.Message)); } }
public static void StatusCheck() { if (Jailed.Count > 0) { for (int i = 0; i < Jailed.Count; i++) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(Jailed[i]); if (_cInfo != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.Spawned && _player.IsAlive()) { string[] _cords = Jail_Position.Split(','); int.TryParse(_cords[0], out int _x); int.TryParse(_cords[1], out int _y); int.TryParse(_cords[2], out int _z); Vector3 _vector3 = _player.position; if ((_x - _vector3.x) * (_x - _vector3.x) + (_z - _vector3.z) * (_z - _vector3.z) >= Jail_Size * Jail_Size) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); if (Jail_Shock) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup("buff buffShocked", true)); Phrases.Dict.TryGetValue(198, out string _phrase198); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase198 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } }
public static void Check(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (_player.IsAlive()) { int _deaths = XUiM_Player.GetDeaths(_player); if (_deaths < Max_Deaths) { int _lives = Max_Deaths - _deaths; string _phrase950; if (!Phrases.Dict.TryGetValue(950, out _phrase950)) { _phrase950 = "Hardcore: Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Score {Score}, Lives remaining {Lives}..."; } _phrase950 = _phrase950.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase950 = _phrase950.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase950 = _phrase950.Replace("{Score}", _player.Score.ToString()); _phrase950 = _phrase950.Replace("{Lives}", _lives.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase950 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { if (Max_Extra_Lives > 0) { string _sql = string.Format("SELECT extraLives FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); int _extraLives; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _extraLives); _result.Dispose(); if (_deaths < Max_Deaths + _extraLives) { int _lives = (Max_Deaths + _extraLives) - _deaths; string _phrase950; if (!Phrases.Dict.TryGetValue(950, out _phrase950)) { _phrase950 = "Hardcore: Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Score {Score}, Lives remaining {Lives}..."; } _phrase950 = _phrase950.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase950 = _phrase950.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase950 = _phrase950.Replace("{Score}", _player.Score.ToString()); _phrase950 = _phrase950.Replace("{Lives}", _lives.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase950 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { EndGame(_cInfo, _player); } } else { EndGame(_cInfo, _player); } } } } }
public static bool IsProtected(EntityPlayer _victim) { if (_victim.IsAlive() && _victim.Progression.Level <= Level) { return(true); } return(false); }
public static void PlayerCheck() { try { if (!IsRunning) { IsRunning = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; Log.Out(string.Format("[SERVERTOOLS] Test 1")); if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0) { Log.Out(string.Format("[SERVERTOOLS] Test 2")); EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { Log.Out(string.Format("[SERVERTOOLS] Test 3")); if (!_player.IsDead()) { if (_player.IsSpawned() && _player.IsAlive()) { if (Zones.IsEnabled) { Zones.ZoneCheck(_cInfo, _player); } if (GodMode.IsEnabled) { GodMode.GodCheck(_cInfo); } } } else { if (BloodmoonWarrior.IsEnabled && BloodmoonWarrior.WarriorList.Contains(_cInfo.entityId)) { BloodmoonWarrior.WarriorList.Remove(_cInfo.entityId); BloodmoonWarrior.KilledZombies.Remove(_cInfo.entityId); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PersistentOperations.PlayerCheck: {0}.", e.Message)); } IsRunning = false; }
public static void RewardWarriors() { try { List <string> _warriors = WarriorList; for (int i = 0; i < _warriors.Count; i++) { string _warrior = _warriors[i]; EntityPlayer _player = PersistentOperations.GetEntityPlayer(_warrior); if (_player != null && _player.IsAlive()) { if (KilledZombies.TryGetValue(_warrior, out int _killedZ)) { if (_killedZ >= Zombie_Kills) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_warrior); if (_cInfo != null) { RandomItem(_cInfo); if (Reduce_Death_Count) { int _deathCount = _player.Died - 1; _player.Died = _deathCount; _player.bPlayerStatsChanged = true; _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerStats>().Setup(_player)); Phrases.Dict.TryGetValue(692, out string _phrase692); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase692 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue(693, out string _phrase693); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase693 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.RewardWarriors: {0}", e.Message)); } WarriorList.Clear(); KilledZombies.Clear(); }
public static void RewardWarriors() { try { List <int> warriors = WarriorList; for (int i = 0; i < warriors.Count; i++) { int warrior = warriors[i]; EntityPlayer player = PersistentOperations.GetEntityPlayer(warrior); if (player != null && player.IsAlive()) { if (KilledZombies.TryGetValue(warrior, out int _killedZ)) { if (_killedZ >= Zombie_Kills) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromEntityId(warrior); if (cInfo != null) { Counter(cInfo, Reward_Count); if (Reduce_Death_Count) { int deathCount = player.Died - 1; player.Died = deathCount; player.bPlayerStatsChanged = true; cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerStats>().Setup(player)); Phrases.Dict.TryGetValue("BloodmoonWarrior2", out string _phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue("BloodmoonWarrior3", out string _phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.RewardWarriors: {0}", e.Message)); } WarriorList.Clear(); KilledZombies.Clear(); }
public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.IsBloodmoon()) { BloodmoonStarted = true; List <ClientInfo> clientList = PersistentOperations.ClientList(); if (clientList != null) { for (int i = 0; i < clientList.Count; i++) { ClientInfo cInfo = clientList[i]; if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null && player.IsSpawned() && player.IsAlive() && player.Died > 0 && player.Progression.GetLevel() >= 10 && Random.Next(0, 100) < Chance) { WarriorList.Add(cInfo.entityId); KilledZombies.Add(cInfo.entityId, 0); Phrases.Dict.TryGetValue("BloodmoonWarrior1", out string phrase); phrase = phrase.Replace("{Count}", Zombie_Kills.ToString()); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } else if (!PersistentOperations.IsBloodmoon()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}", e.Message)); } }
public static void NewPlayerExec2(ClientInfo _cInfo, EntityPlayer _player) { try { if (_player.IsSpawned() && _player.IsAlive()) { if (StartingItems.IsEnabled && StartingItems.ItemList.Count > 0) { StartingItems.SpawnItems(_cInfo); } NewPlayerExec3(_cInfo, _player); } else { Timers.NewPlayerStartingItemsTimer(_cInfo, _player); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec2: {0}.", e.Message)); } }
public static void BattleLog(ClientInfo _cInfo, string _ip) { try { if (DisconnectedIp != null && DisconnectedIp.Count > 0) { if (DisconnectedIp.ContainsKey(_ip)) { if (DisconnectedIp.TryGetValue(_ip, out DateTime _dateTime)) { TimeSpan varTime = DateTime.Now - _dateTime; double fractionalSeconds = varTime.TotalSeconds; int _timepassed = (int)fractionalSeconds; if (_timepassed <= 5) { PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerDataFromSteamId(_cInfo.playerId); PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId); List <EntityPlayer> _players = PersistentOperations.PlayerList(); if (_ppd != null && _pdf != null && _players != null && _players.Count > 0) { if (_ppd.ACL != null && _ppd.ACL.Count > 0)// has friends { for (int i = 0; i < _players.Count; i++) { EntityPlayer _player = _players[i]; if (_player != null && _player.entityId != _cInfo.entityId && _player.IsAlive() && _player.IsSpawned())// player is alive and spawned { PersistentPlayerData _ppd2 = PersistentOperations.GetPersistentPlayerDataFromEntityId(_player.entityId); if (_ppd2 != null && _ppd2.ACL.Count > 0) // player has friends { if (!_ppd.ACL.Contains(_ppd2.PlayerId) || !_ppd2.ACL.Contains(_ppd.PlayerId)) // not a friend { if (Player_Distance > 0) // distance check { if ((_pdf.ecd.pos - _player.position).magnitude <= Player_Distance) { Penalty(_pdf, _cInfo); return; } } else { Penalty(_pdf, _cInfo); return; } } } else { if (Player_Distance > 0)// distance check { if ((_pdf.ecd.pos - _player.position).magnitude <= Player_Distance) { Penalty(_pdf, _cInfo); return; } } else { Penalty(_pdf, _cInfo); return; } } } } } else //no friends { for (int i = 0; i < _players.Count; i++) { EntityPlayer _player = _players[i]; if (_player != null && _player.entityId != _cInfo.entityId && _player.IsAlive() && _player.IsSpawned()) { if (Player_Distance > 0)// distance check { if ((_pdf.ecd.pos - _player.position).magnitude <= Player_Distance) { Penalty(_pdf, _cInfo); return; } } else { Penalty(_pdf, _cInfo); return; } } } } } } } DisconnectedIp.Remove(_ip); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.BattleLog: {0}", e.Message)); } }
private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary) { try { if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null) { EntityPlayer _player1 = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player1 != null) { bool _notice = false; if (!string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName) { ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName); if (_cInfo2 != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { if (KillNotice.IsEnabled && _player2.IsAlive()) { string _holdingItem = _player2.inventory.holdingItem.Name; if (!string.IsNullOrEmpty(_holdingItem)) { ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true); if (_itemValue.type != ItemValue.None.type) { _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName(); KillNotice.Notice(_cInfo, _cInfo2, _holdingItem); _notice = true; } } } if (Zones.IsEnabled) { Zones.Check(_cInfo, _cInfo2); } if (Bounties.IsEnabled) { Bounties.PlayerKilled(_player1, _player2, _cInfo, _cInfo2); } if (Wallet.IsEnabled) { if (Wallet.PVP && Wallet.Player_Kills > 0) { Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills); } else if (Wallet.Player_Kills > 0) { Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills); } } } } } if (DeathSpot.IsEnabled) { DeathSpot.PlayerKilled(_player1); } if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId)) { string _sql = string.Format("UPDATE Players SET eventReturn = 'true' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Players"); } if (_notice) { return(false); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}.", e.Message)); } return(true); }
public static void AddPlayer(ClientInfo _cInfo) { if (!Teams.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (Teams.Count >= PlayerCount) { Phrases.Dict.TryGetValue("Event3", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } EntityPlayer player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (player != null) { Vector3 _position = player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].EventReturnPosition = sposition; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Event4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } EventCommandsConsole.Setup.TryGetValue(Operator, out List <string> setup); Teams.Add(_cInfo.CrossplatformId.CombinedString, TeamSetup); Phrases.Dict.TryGetValue("Event5", out string phrase1); phrase1 = phrase1.Replace("{Value}", TeamSetup.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); TeamSetup--; if (TeamSetup == 0) { TeamSetup = TeamCount; } if (Teams.Count == PlayerCount) { Invited = false; foreach (var teamPlayer in Teams) { ClientInfo eventClientInfo = PersistentOperations.GetClientInfoFromNameOrId(teamPlayer.Key); if (eventClientInfo != null) { EntityPlayer eventPlayer = GameManager.Instance.World.Players.dict[eventClientInfo.entityId]; if (eventPlayer != null && eventPlayer.IsAlive()) { Teams.TryGetValue(teamPlayer.Key, out int _teamNumber); string spawnPosition = setup[_teamNumber + 4]; string[] cords = spawnPosition.Split(','); int.TryParse(cords[0], out int x); int.TryParse(cords[1], out int y); int.TryParse(cords[2], out int z); eventClientInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); } else { PersistentContainer.Instance.Players[eventClientInfo.CrossplatformId.CombinedString].EventSpawn = true; PersistentContainer.DataChange = true; } } else { PersistentContainer.Instance.Players[eventClientInfo.CrossplatformId.CombinedString].EventSpawn = true; PersistentContainer.DataChange = true; } } int eventTime = Time * 60; Timers.eventTime = eventTime; Open = true; Phrases.Dict.TryGetValue("Event6", out string _phrase); _phrase = _phrase.Replace("{EventName}", TeamSetup.ToString()); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue("Event7", out string _phrase); _phrase = _phrase.Replace("{EventName}", TeamSetup.ToString()); _phrase = _phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); _phrase = _phrase.Replace("{Command_join}", Command_join); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); Phrases.Dict.TryGetValue("Event8", out _phrase); _phrase = _phrase.Replace("{Value}", Teams.Count.ToString()); _phrase = _phrase.Replace("{PlayerTotal}", PlayerCount.ToString()); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } else { Phrases.Dict.TryGetValue("Event9", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
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 void AddPlayer(ClientInfo _cInfo) { if (!Teams.ContainsKey(_cInfo.playerId)) { if (Teams.Count >= PlayerCount) { Phrases.Dict.TryGetValue(773, out string _phrase773); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase773 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.playerId].EventReturnPosition = _sposition; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(774, out string _phrase774); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase774 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } EventCommandsConsole.Setup.TryGetValue(Operator, out List <string> _setup); Teams.Add(_cInfo.playerId, TeamSetup); Phrases.Dict.TryGetValue(775, out string _phrase775); _phrase775 = _phrase775.Replace("{Value}", TeamSetup.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase775 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); TeamSetup--; if (TeamSetup == 0) { TeamSetup = TeamCount; } if (Teams.Count == PlayerCount) { Invited = false; foreach (var _teamPlayer in Teams) { ClientInfo _eventClientInfo = ConnectionManager.Instance.Clients.ForPlayerId(_teamPlayer.Key); if (_eventClientInfo != null) { EntityPlayer _eventPlayer = GameManager.Instance.World.Players.dict[_eventClientInfo.entityId]; if (_eventPlayer != null && _eventPlayer.IsAlive()) { Teams.TryGetValue(_teamPlayer.Key, out int _teamNumber); string _spawnPosition = _setup[_teamNumber + 4]; int _x, _y, _z; string[] _cords = _spawnPosition.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _eventClientInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); } else { PersistentContainer.Instance.Players[_eventClientInfo.playerId].EventSpawn = true; PersistentContainer.Instance.Save(); } } else { PersistentContainer.Instance.Players[_eventClientInfo.playerId].EventSpawn = true; PersistentContainer.Instance.Save(); } } int _eventTime = Time * 60; Timers._eventTime = _eventTime; Open = true; Phrases.Dict.TryGetValue(776, out string _phrase776); _phrase776 = _phrase776.Replace("{EventName}", TeamSetup.ToString()); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase776 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue(777, out string _phrase777); _phrase777 = _phrase777.Replace("{EventName}", TeamSetup.ToString()); _phrase777 = _phrase777.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase777 = _phrase777.Replace("{Command100}", Command100); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase777 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); Phrases.Dict.TryGetValue(778, out string _phrase778); _phrase778 = _phrase778.Replace("{Value}", Teams.Count.ToString()); _phrase778 = _phrase778.Replace("{PlayerTotal}", PlayerCount.ToString()); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase778 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } else { Phrases.Dict.TryGetValue(779, out string _phrase779); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase779 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary) { try { if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (DeathSpot.IsEnabled) { DeathSpot.PlayerKilled(_player); } if (!string.IsNullOrEmpty(_secondaryName) && !string.IsNullOrEmpty(_mainName) && _mainName != _secondaryName) { ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName); if (_cInfo2 != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo2.entityId)) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { if (Bounties.IsEnabled) { Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2); } if (Wallet.IsEnabled) { if (Wallet.PVP && Wallet.Player_Kills > 0) { Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills); } else if (Wallet.Player_Kills > 0) { Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills); } } if (KillNotice.IsEnabled && _player2.IsAlive()) { string _holdingItem = _player2.inventory.holdingItem.Name; if (!string.IsNullOrEmpty(_holdingItem)) { ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true); if (_itemValue.type != ItemValue.None.type) { _holdingItem = _itemValue.ItemClass.GetItemName(); KillNotice.Exec(_cInfo, _player, _cInfo2, _player2, _holdingItem); return(false); } } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message)); } return(true); }
public static void AddPlayer(ClientInfo _cInfo) { if (!Teams.ContainsKey(_cInfo.playerId)) { if (Teams.Count >= PlayerCount) { ChatHook.ChatMessage(_cInfo, "The event is full. Unable to join.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.playerId].EventReturnPosition = _sposition; PersistentContainer.Instance.Save(); ChatHook.ChatMessage(_cInfo, "You have signed up for the event and your current location has been saved for return.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } EventCommandsConsole.Setup.TryGetValue(Operator, out List <string> _setup); Teams.Add(_cInfo.playerId, TeamSetup); string _message = "You are on team {Team}."; _message = _message.Replace("{Team}", TeamSetup.ToString()); ChatHook.ChatMessage(_cInfo, _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); TeamSetup--; if (TeamSetup == 0) { TeamSetup = TeamCount; } if (Teams.Count == PlayerCount) { Invited = false; foreach (var _teamPlayer in Teams) { ClientInfo _eventClientInfo = ConnectionManager.Instance.Clients.ForPlayerId(_teamPlayer.Key); if (_eventClientInfo != null) { EntityPlayer _eventPlayer = GameManager.Instance.World.Players.dict[_eventClientInfo.entityId]; if (_eventPlayer != null && _eventPlayer.IsAlive()) { Teams.TryGetValue(_teamPlayer.Key, out int _teamNumber); string _spawnPosition = _setup[_teamNumber + 4]; int _x, _y, _z; string[] _cords = _spawnPosition.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _eventClientInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); ChatHook.ChatMessage(_eventClientInfo, LoadConfig.Chat_Response_Color + "You have been sent to your event spawn point.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { PersistentContainer.Instance.Players[_eventClientInfo.playerId].EventSpawn = true; PersistentContainer.Instance.Save(); } } else { PersistentContainer.Instance.Players[_eventClientInfo.playerId].EventSpawn = true; PersistentContainer.Instance.Save(); } } int _eventTime = Time * 60; Timers._eventTime = _eventTime; Open = true; _message = "{EventName} has now started."; _message = _message.Replace("{EventName}", EventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { _message = "{EventName} still has space for more players. Type " + ChatHook.Command_Private + Command100 + "."; _message = _message.Replace("{EventName}", EventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); _message = "{Count} of {PlayerTotal} have joined the event."; _message = _message.Replace("{Count}", Teams.Count.ToString()); _message = _message.Replace("{PlayerTotal}", PlayerCount.ToString()); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have already joined this event. It will start when enough players sign up.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.BloodMoonSky()) { BloodmoonStarted = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null && _player.IsSpawned() && _player.IsAlive() && _player.Died > 0 && _player.Progression.GetLevel() >= 10 && random.Next(0, 100) < Chance) { WarriorList.Add(_cInfo.playerId); KilledZombies.Add(_cInfo.playerId, 0); Phrases.Dict.TryGetValue(691, out string _phrase691); _phrase691 = _phrase691.Replace("{Count}", Zombie_Kills.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase691 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } } else if (!PersistentOperations.BloodMoonSky()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}", e.Message)); } }
public override void PlayerDisconnected(ClientInfo _cInfo, bool _bShutdown) { if (_cInfo != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (_player.IsAlive()) { PersistentContainer.Instance.Players[_cInfo.playerId, true].ZKills = XUiM_Player.GetZombieKills(_player); PersistentContainer.Instance.Players[_cInfo.playerId, true].Deaths = XUiM_Player.GetDeaths(_player); PersistentContainer.Instance.Players[_cInfo.playerId, true].Kills = XUiM_Player.GetPlayerKills(_player); PersistentContainer.Instance.Save(); } } if (HatchElevator.LastPositionY.ContainsKey(_cInfo.entityId)) { HatchElevator.LastPositionY.Remove(_cInfo.entityId); } if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId)) { FriendTeleport.Dict.Remove(_cInfo.entityId); FriendTeleport.Dict1.Remove(_cInfo.entityId); } if (Players.ZoneExit.ContainsKey(_cInfo.entityId)) { Players.ZoneExit.Remove(_cInfo.entityId); Players.Forgive.Remove(_cInfo.entityId); Players.Victim.Remove(_cInfo.entityId); } if (FlightCheck.Flag.ContainsKey(_cInfo.entityId)) { FlightCheck.Flag.Remove(_cInfo.entityId); } if (FlightCheck.fLastPositionXZ.ContainsKey(_cInfo.entityId)) { FlightCheck.fLastPositionXZ.Remove(_cInfo.entityId); } if (FlightCheck.fLastPositionY.ContainsKey(_cInfo.entityId)) { FlightCheck.fLastPositionY.Remove(_cInfo.entityId); } if (FriendTeleport.Dict.ContainsKey(_cInfo.entityId)) { FriendTeleport.Dict.Remove(_cInfo.entityId); } if (FriendTeleport.Dict1.ContainsKey(_cInfo.entityId)) { FriendTeleport.Dict1.Remove(_cInfo.entityId); } if (Travel.Flag.Contains(_cInfo.entityId)) { Travel.Flag.Remove(_cInfo.entityId); } if (UndergroundCheck.Flag.ContainsKey(_cInfo.entityId)) { UndergroundCheck.Flag.Remove(_cInfo.entityId); } if (UndergroundCheck.uLastPositionXZ.ContainsKey(_cInfo.entityId)) { UndergroundCheck.uLastPositionXZ.Remove(_cInfo.entityId); } if (PersistentContainer.Instance.Players[_cInfo.playerId, false] != null) { DateTime _time; if (Players.Session.TryGetValue(_cInfo.playerId, out _time)) { TimeSpan varTime = DateTime.Now - _time; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed > 60) { int _hours = _timepassed / 60 * 10; int _oldCoin = PersistentContainer.Instance.Players[_cInfo.playerId, false].PlayerSpentCoins; PersistentContainer.Instance.Players[_cInfo.playerId, true].PlayerSpentCoins = _oldCoin + _hours; } int _oldSession = PersistentContainer.Instance.Players[_cInfo.playerId, false].SessionTime; PersistentContainer.Instance.Players[_cInfo.playerId, true].SessionTime = _oldSession + _timepassed; PersistentContainer.Instance.Save(); } } if (Players.Session.ContainsKey(_cInfo.playerId)) { Players.Session.Remove(_cInfo.playerId); } if (Bank.TransferId.ContainsKey(_cInfo.playerId)) { Bank.TransferId.Remove(_cInfo.playerId); } } }
public static void AddPlayer(ClientInfo _cInfo) { if (!PlayersTeam.ContainsKey(_cInfo.playerId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; string _eventReturn = SQL.EscapeString(_sposition); string _sql = string.Format("UPDATE Players SET eventReturn = '{0}' WHERE steamid = {1}", _eventReturn, _cInfo.playerId); SQL.FastQuery(_sql); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have signed up for the event and your current location has been saved for return.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); _sql = string.Format("SELECT eventid, eventName, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Admin); DataTable _result1 = SQL.TQuery(_sql); int _eventid; int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); string _eventName = _result1.Rows[0].ItemArray.GetValue(1).ToString(); int _eventTeams; int.TryParse(_result1.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams); int _eventPlayerCount; int.TryParse(_result1.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount); int _time; int.TryParse(_result1.Rows[0].ItemArray.GetValue(4).ToString(), out _time); _result1.Dispose(); PlayersTeam.Add(_cInfo.playerId, TeamCount); string _message = "you are on team {Team}."; _message = _message.Replace("{Team}", TeamCount.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); if (TeamCount == _eventTeams) { TeamCount = 1; } if (PlayersTeam.Count == _eventPlayerCount) { Invited = false; foreach (var _eventPlayer in PlayersTeam) { ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_eventPlayer.Key); if (_cInfo2 != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null && _player2.IsAlive()) { int _teamNumber; PlayersTeam.TryGetValue(_eventPlayer.Key, out _teamNumber); _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _teamNumber); DataTable _result2 = SQL.TQuery(_sql); string _spawnPos = _result2.Rows[0].ItemArray.GetValue(0).ToString(); _result2.Dispose(); int _x, _y, _z; string[] _cords = _spawnPos.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _cInfo2.SendPackage(new NetPackageTeleportPlayer(new Vector3(_x, _y, _z), null, false)); ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + ", you have been sent to your event spawn point.[-]", _cInfo2.entityId, _cInfo2.playerName, EChatType.Global, null); } else { _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key); SQL.FastQuery(_sql); } } else { _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key); SQL.FastQuery(_sql); } } int _eventTime = _time * 60; Timers._eventTime = _eventTime; Open = true; _message = "{EventName} is full and has now started."; _message = _message.Replace("{EventName}", _eventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { _message = "{EventName} still has space for more players. Type /event."; _message = _message.Replace("{EventName}", _eventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); _message = "{Count} of {Total} have signed up."; _message = _message.Replace("{Count}", PlayersTeam.Count.ToString()); _message = _message.Replace("{Total}", _eventPlayerCount.ToString()); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are already signed up for this event. It will start when enough players sign up.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } }
private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary) { try { if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (PlayerChecks.FlyEnabled && PlayerChecks.Movement.ContainsKey(_cInfo.entityId)) { PlayerChecks.Movement.Remove(_cInfo.entityId); } if (Died.IsEnabled) { Died.PlayerKilled(_player); } if (KillNotice.IsEnabled) { if (KillNotice.Zombie_Kills && string.IsNullOrEmpty(_secondaryName)) { List <Entity> Entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < Entities.Count; i++) { EntityAlive _entityAlive = Entities[i] as EntityAlive; if (_entityAlive != null && _entityAlive.GetAttackTarget() == _player && _entityAlive.entityId != _player.entityId) { if (KillNotice.Show_Level) { Phrases.Dict.TryGetValue(545, out string _phrase545); _phrase545 = _phrase545.Replace("{PlayerName}", _cInfo.playerName); _phrase545 = _phrase545.Replace("{Level}", _player.Progression.Level.ToString()); _phrase545 = _phrase545.Replace("{ZombieName}", _entityAlive.EntityName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase545 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue(546, out string _phrase546); _phrase546 = _phrase546.Replace("{PlayerName}", _cInfo.playerName); _phrase546 = _phrase546.Replace("{ZombieName}", _entityAlive.EntityName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + _phrase546 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } } } } else if (KillNotice.PvP && !string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName) { ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName); if (_cInfo2 != null && GameManager.Instance.World.Players.dict.ContainsKey(_cInfo2.entityId)) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { if (KillNotice.IsEnabled && _player2.IsAlive()) { string _holdingItem = _player2.inventory.holdingItem.GetItemName(); if (!string.IsNullOrEmpty(_holdingItem)) { ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true); if (_itemValue.type != ItemValue.None.type) { KillNotice.Exec(_cInfo, _player, _cInfo2, _player2, _holdingItem); return(false); } } } if (Wallet.IsEnabled) { if (Wallet.PVP && Wallet.Player_Kills > 0) { Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills); } else if (Wallet.Player_Kills > 0) { Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills); } } if (Bounties.IsEnabled) { Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}", e.Message)); } return(true); }
public static void AutoFlightCheck() { if (ConnectionManager.Instance.ClientCount() > 0) { World world = GameManager.Instance.World; List <ClientInfo> _cInfoList = ConnectionManager.Instance.Clients.List.ToList(); for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId); AdminToolsClientInfo Admin = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId); if (Admin.PermissionLevel > Admin_Level) { if (!Players.NoFlight.Contains(_cInfo.entityId)) { EntityPlayer ep = world.Players.dict[_cInfo.entityId]; if (!ep.IsAlive() || !ep.IsSpawned()) { continue; } if (autoGetFlightCheck(ep, _cInfo) && ep.AttachedToEntity == null) { if (!Flag.ContainsKey(_cInfo.entityId)) { Flag.Add(_cInfo.entityId, 1); } else { int _value; if (Flag.TryGetValue(_cInfo.entityId, out _value)) { if (_value == 1) { Flag[_cInfo.entityId] = 2; } else { int x = (int)ep.position.x; int y = (int)ep.position.y; int z = (int)ep.position.z; _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, -1, z), null, false)); Penalty(_cInfo); 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(); } for (int j = 0; j < _cInfoList.Count; j++) { ClientInfo _cInfo1 = _cInfoList[j]; AdminToolsClientInfo Admin1 = GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo1.playerId); if (Admin1.PermissionLevel <= Admin_Level) { string _phrase706; if (!Phrases.Dict.TryGetValue(706, out _phrase706)) { _phrase706 = "Cheat Detected: {PlayerName} flying @ {X} {Y} {Z}"; } _phrase706 = _phrase706.Replace("{PlayerName}", _cInfo.playerName); _phrase706 = _phrase706.Replace("{X}", x.ToString()); _phrase706 = _phrase706.Replace("{Y}", y.ToString()); _phrase706 = _phrase706.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(null, "[FF0000]" + _phrase706 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } if (Announce) { string _phrase707; if (!Phrases.Dict.TryGetValue(707, out _phrase707)) { _phrase707 = "Cheat Detected: {PlayerName} has been detected flying."; } _phrase707 = _phrase707.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, "[FF0000]" + _phrase707 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } } } } else { Flag.Remove(_cInfo.entityId); } } else { Flag.Remove(_cInfo.entityId); } } } } } }
public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.BloodMoonSky()) { BloodmoonStarted = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null && _player.IsSpawned() && _player.IsAlive() && _player.Died > 0 && _player.Progression.GetLevel() >= 10 && random.Next(0, 100) < Chance) { WarriorList.Add(_cInfo.playerId); KilledZombies.Add(_cInfo.playerId, 0); string _response = "Hades has called upon you. Survive this night and kill {ZombieCount} zombies to be rewarded by the king of the underworld."; _response = _response.Replace("{ZombieCount}", Zombie_Kills.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _response + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); Thread.Sleep(TimeSpan.FromMilliseconds(30)); } } } } } } } else if (!PersistentOperations.BloodMoonSky()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}", e.Message)); } }
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 bool Exec(NetPackageDamageEntity __instance) { try { Entity victim = PersistentOperations.GetEntity(entityId(__instance)); if (victim != null) { Entity attacker = PersistentOperations.GetEntity(attackerEntityId(__instance)); if (attacker != null) { if (victim is EntityPlayer) { ClientInfo cInfoVictim = PersistentOperations.GetClientInfoFromEntityId(victim.entityId); if (cInfoVictim != null) { EntityPlayer victimPlayer = victim as EntityPlayer; if (attacker is EntityPlayer) { ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId); if (cInfoAttacker != null) { EntityPlayer attackingPlayer = attacker as EntityPlayer; if (attackingItem(__instance) != null) { if (DamageDetector.IsEnabled && !DamageDetector.IsValidPvP(victim as EntityPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance))) { return(true); } if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun()) { int slot = attackingPlayer.inventory.holdingItemIdx; if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance))) { return(true); } } } else { return(true); } if (NewPlayerProtection.IsEnabled) { if (NewPlayerProtection.IsProtected(victimPlayer)) { Phrases.Dict.TryGetValue("NewPlayerProtection2", out string phrase); ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(true); } else if (NewPlayerProtection.IsProtected(attackingPlayer)) { Phrases.Dict.TryGetValue("NewPlayerProtection1", out string phrase); ChatHook.ChatMessage(cInfoVictim, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(true); } } //if (Zones.IsEnabled && !Zones.IsValid(cInfoVictim, cInfoAttacker)) //{ // return true; //} if (Lobby.IsEnabled && Lobby.PvE && (Lobby.LobbyPlayers.Contains(victimPlayer.entityId) || Lobby.LobbyPlayers.Contains(attackingPlayer.entityId))) { Lobby.PvEViolation(cInfoAttacker); return(true); } if (Market.IsEnabled && Market.PvE && (Market.MarketPlayers.Contains(victimPlayer.entityId) || Market.MarketPlayers.Contains(attackingPlayer.entityId))) { Market.PvEViolation(cInfoAttacker); return(true); } float distance = attackingPlayer.GetDistance(victimPlayer); using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' @ '{4}' hit '{5}' '{6}' named '{7}' @ '{8}' using '{9}' for '{10}' damage. Distance '{11}'", DateTime.Now, cInfoAttacker.PlatformId.CombinedString, cInfoAttacker.CrossplatformId.CombinedString, cInfoAttacker.playerName, cInfoAttacker.latestPlayerData.ecd.pos, cInfoVictim.PlatformId.CombinedString, cInfoVictim.CrossplatformId.CombinedString, cInfoVictim.playerName, cInfoVictim.latestPlayerData.ecd.pos, attackingItem(__instance).ItemClass.GetLocalizedItemName() ?? attackingItem(__instance).ItemClass.GetItemName(), strength(__instance), distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } if (bFatal(__instance) && victimPlayer.IsAlive() && lastEntityKilled != victimPlayer.entityId) { lastEntityKilled = victimPlayer.entityId; if (KillNotice.IsEnabled && KillNotice.PvP) { KillNotice.PlayerKilledPlayer(cInfoVictim, victimPlayer, cInfoAttacker, attackingPlayer, attackingItem(__instance), strength(__instance)); } if (Bounties.IsEnabled) { Bounties.PlayerKilled(victimPlayer, attackingPlayer, cInfoVictim, cInfoAttacker); } if (Wallet.IsEnabled && Wallet.PVP && Wallet.Player_Kill > 0) { Wallet.AddCurrency(cInfoAttacker.CrossplatformId.CombinedString, Wallet.Player_Kill); } if (MagicBullet.IsEnabled && !MagicBullet.Kill.Contains(cInfoAttacker.entityId)) { MagicBullet.Kill.Add(cInfoAttacker.entityId); } } } } else if (attacker is EntityZombie) { if (NewPlayerProtection.IsEnabled && NewPlayerProtection.IsProtected(victimPlayer)) { return(true); } if (KillNotice.IsEnabled && KillNotice.Zombie_Kills) { int[] attack = new int[] { attacker.entityId, strength(__instance) }; if (KillNotice.Damage.ContainsKey(victim.entityId)) { KillNotice.Damage[victim.entityId] = attack; } else { KillNotice.Damage.Add(victim.entityId, attack); } } } else if (attacker is EntityAnimal) { if (NewPlayerProtection.IsEnabled && NewPlayerProtection.IsProtected(victimPlayer)) { return(true); } if (KillNotice.IsEnabled && KillNotice.Animal_Kills) { int[] attack = new int[] { attacker.entityId, strength(__instance) }; if (KillNotice.Damage.ContainsKey(victim.entityId)) { KillNotice.Damage[victim.entityId] = attack; } else { KillNotice.Damage.Add(victim.entityId, attack); } } } } } else if (victim is EntityZombie && attacker is EntityPlayer) { ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId); if (cInfoAttacker != null) { EntityPlayer attackingPlayer = attacker as EntityPlayer; if (attackingItem(__instance) != null) { if (DamageDetector.IsEnabled && !DamageDetector.IsValidEntityDamage(attackingPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance))) { return(true); } if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun()) { int slot = attackingPlayer.inventory.holdingItemIdx; if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance))) { return(true); } } if (bFatal(__instance) && victim.IsAlive() && lastEntityKilled != victim.entityId) { lastEntityKilled = victim.entityId; if (Wallet.IsEnabled && Wallet.Zombie_Kill > 0) { Wallet.AddCurrency(cInfoAttacker.CrossplatformId.CombinedString, Wallet.Zombie_Kill); } if (BloodmoonWarrior.IsEnabled && BloodmoonWarrior.BloodmoonStarted && BloodmoonWarrior.WarriorList.Contains(cInfoAttacker.entityId)) { if (BloodmoonWarrior.KilledZombies.TryGetValue(cInfoAttacker.entityId, out int killedZ)) { BloodmoonWarrior.KilledZombies[cInfoAttacker.entityId] += 1; } else { BloodmoonWarrior.KilledZombies.Add(cInfoAttacker.entityId, 1); } } } } else { return(true); } if (PersistentOperations.IsBloodmoon() && Market.IsEnabled && Market.MarketPlayers.Contains(cInfoAttacker.entityId)) { Phrases.Dict.TryGetValue("Market12", out string phrase); ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(true); } if (PersistentOperations.IsBloodmoon() && Lobby.IsEnabled && Lobby.LobbyPlayers.Contains(cInfoAttacker.entityId)) { Phrases.Dict.TryGetValue("Lobby12", out string phrase); ChatHook.ChatMessage(cInfoAttacker, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return(true); } int distance = (int)attackingPlayer.GetDistance(victim); using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' @ '{4}' hit '{5}' named '{6}' @ '{7}' using '{8}' for '{9}' damage. Distance '{10}'", DateTime.Now, cInfoAttacker.PlatformId.CombinedString, cInfoAttacker.CrossplatformId.CombinedString, cInfoAttacker.playerName, cInfoAttacker.latestPlayerData.ecd.pos, victim.entityId, victim.EntityClass.entityClassName, victim.position, attackingItem(__instance).ItemClass.GetLocalizedItemName() ?? attackingItem(__instance).ItemClass.GetItemName(), strength(__instance), distance)); sw.WriteLine(); sw.Flush(); sw.Close(); } } } else if (victim is EntityAnimal && attacker is EntityPlayer) { ClientInfo cInfoAttacker = PersistentOperations.GetClientInfoFromEntityId(attacker.entityId); if (cInfoAttacker != null) { EntityPlayer attackingPlayer = attacker as EntityPlayer; if (attackingItem(__instance) != null) { if (DamageDetector.IsEnabled && !DamageDetector.IsValidEntityDamage(attackingPlayer, cInfoAttacker, strength(__instance), attackingItem(__instance))) { return(true); } if (InfiniteAmmo.IsEnabled && attackingItem(__instance).ItemClass.IsGun()) { int slot = attackingPlayer.inventory.holdingItemIdx; if (InfiniteAmmo.Exec(cInfoAttacker, attackingPlayer, slot, attackingItem(__instance))) { return(true); } } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ProcessDamage.Exec: {0}", e.Message)); } return(false); }