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); }
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 PlayerCheck() { if (!IsRunning2) { IsRunning2 = true; if (ConnectionManager.Instance.ClientCount() > 0) { List <EntityPlayer> EntityPlayerList = GameManager.Instance.World.Players.list; for (int i = 0; i < EntityPlayerList.Count; i++) { EntityPlayer _player = EntityPlayerList[i]; if (_player != null) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForEntityId(_player.entityId); if (_cInfo != null) { if (!_player.IsDead() && _player.Spawned) { if (Zones.IsEnabled) { Zones.ZoneCheck(_cInfo, _player); } if (GodModeFlight.IsEnabled) { GodModeFlight.GodFlightCheck(_cInfo); } } else if (_player.IsDead()) { if (!Died.Contains(_player.entityId)) { Died.Add(_player.entityId); if (KillNotice.IsEnabled || Bounties.IsEnabled || Zones.IsEnabled) { for (int j = 0; j < EntityPlayerList.Count; j++) { EntityPlayer _player2 = EntityPlayerList[j]; if (_player != _player2) { ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_player2.entityId); if (_cInfo2 != null) { Entity _target = _player2.GetDamagedTarget(); if (_player == _target) { if (KillNotice.IsEnabled) { string _holdingItem = _player2.inventory.holdingItem.Name; ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true); if (_itemValue.type != ItemValue.None.type) { _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name; } KillNotice.Notice(_cInfo, _cInfo2, _holdingItem); } if (Bounties.IsEnabled) { Bounties.PlayerKilled(_player, _player2, _cInfo, _cInfo2); } if (Zones.IsEnabled) { Zones.Check(_cInfo, _cInfo2); } break; } } } } } if (DeathSpot.IsEnabled) { DeathSpot.PlayerKilled(_player); } if (Wallet.IsEnabled && Wallet.Lose_On_Death) { string _sql = string.Format("SELECT playerSpentCoins FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); int _playerSpentCoins; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins); _result.Dispose(); int _currentCoins = Wallet.GetcurrentCoins(_cInfo); if (_currentCoins >= 1) { _sql = string.Format("UPDATE Players SET playerSpentCoins = {0} WHERE steamid = '{1}'", _playerSpentCoins - _currentCoins, _cInfo.playerId); SQL.FastQuery(_sql, "Players"); } } 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"); } } } } } } } IsRunning2 = false; } }
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 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); }