Example #1
0
        public static void Exec()
        {
            DP = false;
            List <EntityPlayer> _playerList = GameManager.Instance.World.Players.list;

            for (int i = 0; i < _playerList.Count; i++)
            {
                EntityPlayer _player = _playerList[i];
                if (_player != null)
                {
                    if (_player.IsDead())
                    {
                        DP = true;
                        if (!Dead.Contains(_player.entityId))
                        {
                            Dead.Add(_player.entityId);
                            if (!DeathTime.ContainsKey(_player.entityId))
                            {
                                Vector3 _position  = _player.GetPosition();
                                int     x          = (int)_position.x;
                                int     y          = (int)_position.y;
                                int     z          = (int)_position.z;
                                string  _dposition = x + "," + y + "," + z;
                                DeathTime.Add(_player.entityId, DateTime.Now);
                                LastDeathPos.Add(_player.entityId, _dposition);
                            }
                            else
                            {
                                Vector3 _position  = _player.GetPosition();
                                int     x          = (int)_position.x;
                                int     y          = (int)_position.y;
                                int     z          = (int)_position.z;
                                string  _dposition = x + "," + y + "," + z;
                                DeathTime[_player.entityId]    = DateTime.Now;
                                LastDeathPos[_player.entityId] = _dposition;
                            }
                            for (int j = 0; j < _playerList.Count; j++)
                            {
                                EntityPlayer _player2 = _playerList[j];
                                Entity       _target  = _player2.GetDamagedTarget();
                                if (_target == _player && _player != _player2)
                                {
                                    _player2.ClearDamagedTarget();
                                    ClientInfo _cInfo  = ConnectionManager.Instance.GetClientInfoForEntityId(_player.entityId);
                                    ClientInfo _cInfo2 = ConnectionManager.Instance.GetClientInfoForEntityId(_player2.entityId);
                                    if (_cInfo != null && _cInfo2 != null)
                                    {
                                        if (Kill_Notice)
                                        {
                                            string _holdingItem = _player2.inventory.holdingItem.Name;
                                            if (_holdingItem == "handPlayer")
                                            {
                                                _holdingItem = "Fists of Fury";
                                            }
                                            ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                            if (_itemValue.type != ItemValue.None.type)
                                            {
                                                _holdingItem = _itemValue.ItemClass.localizedName ?? _itemValue.ItemClass.Name;
                                            }
                                            string _phrase915;
                                            if (!Phrases.Dict.TryGetValue(915, out _phrase915))
                                            {
                                                _phrase915 = "{PlayerName} has killed {Victim} with {Item}.";
                                            }
                                            _phrase915 = _phrase915.Replace("{PlayerName}", _cInfo2.playerName);
                                            _phrase915 = _phrase915.Replace("{Victim}", _cInfo.playerName);
                                            _phrase915 = _phrase915.Replace("{Item}", _holdingItem);
                                            GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase915), Config.Server_Response_Name, false, "ServerTools", false);
                                        }
                                        if (Bounties.IsEnabled)
                                        {
                                            if (!_player.IsFriendsWith(_player2) || !_player2.IsFriendsWith(_player))
                                            {
                                                if (Friends.ContainsKey(_player.entityId))
                                                {
                                                    string _friends;
                                                    if (Friends.TryGetValue(_player.entityId, out _friends))
                                                    {
                                                        string[] _friendList = _friends.Split(' ').ToArray();
                                                        for (int k = 0; k < _friendList.Length; k++)
                                                        {
                                                            string _friend = _friendList[k];
                                                            if (_friend == _cInfo2.playerId)
                                                            {
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (Friends.ContainsKey(_player2.entityId))
                                                {
                                                    string _friends;
                                                    if (Friends.TryGetValue(_player2.entityId, out _friends))
                                                    {
                                                        string[] _friendList = _friends.Split(' ').ToArray();
                                                        for (int k = 0; k < _friendList.Length; k++)
                                                        {
                                                            string _friend = _friendList[k];
                                                            if (_friend == _cInfo.playerId)
                                                            {
                                                                return;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (ClanManager.IsEnabled)
                                                {
                                                    if (ClanManager.ClanMember.Contains(_cInfo.playerId) && ClanManager.ClanMember.Contains(_cInfo2.playerId))
                                                    {
                                                        Player p  = PersistentContainer.Instance.Players[_cInfo.playerId, false];
                                                        Player p2 = PersistentContainer.Instance.Players[_cInfo2.playerId, false];
                                                        if (p != null && p2 != null)
                                                        {
                                                            if (p.ClanName != null && p2.ClanName != null)
                                                            {
                                                                if (p.ClanName == p2.ClanName)
                                                                {
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                int _bounty = PersistentContainer.Instance.Players[_cInfo.playerId, true].Bounty;
                                                if (_bounty > 0)
                                                {
                                                    int _oldCoins = PersistentContainer.Instance.Players[_cInfo2.playerId, true].PlayerSpentCoins;
                                                    PersistentContainer.Instance.Players[_cInfo2.playerId, true].PlayerSpentCoins = _oldCoins + _bounty;
                                                    PersistentContainer.Instance.Players[_cInfo.playerId, true].Bounty            = 0;
                                                    PersistentContainer.Instance.Save();
                                                    string _phrase912;
                                                    if (!Phrases.Dict.TryGetValue(912, out _phrase912))
                                                    {
                                                        _phrase912 = "{PlayerName} is a bounty hunter! {Victim} was snuffed out.";
                                                    }
                                                    _phrase912 = _phrase912.Replace("{PlayerName}", _cInfo2.playerName);
                                                    _phrase912 = _phrase912.Replace("{Victim}", _cInfo.playerName);
                                                    GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase912), Config.Server_Response_Name, false, "ServerTools", false);
                                                    using (StreamWriter sw = new StreamWriter(filepath, true))
                                                    {
                                                        sw.WriteLine(string.Format("{0}: {1} is a bounty hunter! {2} was snuffed out. Bounty was worth {3}", DateTime.Now, _cInfo2.playerName, _cInfo.playerName, _bounty));
                                                        sw.WriteLine();
                                                        sw.Flush();
                                                        sw.Close();
                                                    }
                                                }
                                                if (Bounties.Kill_Streak > 0)
                                                {
                                                    if (KillStreak.ContainsKey(_cInfo.entityId))
                                                    {
                                                        KillStreak.Remove(_cInfo.entityId);
                                                        using (StreamWriter sw = new StreamWriter(filepath, true))
                                                        {
                                                            sw.WriteLine(string.Format("{0}: Player {1} kill streak has come to an end by {2}.", DateTime.Now, _cInfo.playerName, _cInfo2.playerName));
                                                            sw.WriteLine();
                                                            sw.Flush();
                                                            sw.Close();
                                                        }
                                                    }
                                                    if (KillStreak.ContainsKey(_cInfo2.entityId))
                                                    {
                                                        int _value;
                                                        if (KillStreak.TryGetValue(_cInfo2.entityId, out _value))
                                                        {
                                                            int _newValue = _value + 1;
                                                            KillStreak[_cInfo2.entityId] = _newValue;
                                                            if (_newValue == Bounties.Kill_Streak)
                                                            {
                                                                string _phrase913;
                                                                if (!Phrases.Dict.TryGetValue(913, out _phrase913))
                                                                {
                                                                    _phrase913 = "{PlayerName} is on a kill streak! Their bounty has increased.";
                                                                }
                                                                _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName);
                                                                GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase913), Config.Server_Response_Name, false, "ServerTools", false);
                                                            }
                                                            if (_newValue >= Bounties.Kill_Streak)
                                                            {
                                                                int _oldBounty = PersistentContainer.Instance.Players[_cInfo2.playerId, true].Bounty;
                                                                PersistentContainer.Instance.Players[_cInfo.playerId, true].Bounty = _oldBounty + (_player2.Level * Bounties.Bounty);
                                                                PersistentContainer.Instance.Save();
                                                                using (StreamWriter sw = new StreamWriter(filepath, true))
                                                                {
                                                                    sw.WriteLine(string.Format("{0}: {1} is on a kill streak of {2}. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _newValue));
                                                                    sw.WriteLine();
                                                                    sw.Flush();
                                                                    sw.Close();
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        KillStreak.Add(_cInfo2.entityId, 1);
                                                    }
                                                }
                                            }
                                        }
                                        if (Zones.IsEnabled)
                                        {
                                            Zones.Check(_cInfo2, _cInfo);
                                        }
                                    }
                                }
                            }
                            if (Event.Open && Event.Players.Contains(_player.entityId) && !Event.SpawnList.Contains(_player.entityId))
                            {
                                Event.SpawnList.Add(_player.entityId);
                            }
                        }
                    }
                    else
                    {
                        if (Zones.IsEnabled)
                        {
                            ClientInfo _cInfo = ConnectionManager.Instance.GetClientInfoForEntityId(_player.entityId);
                            if (_cInfo != null)
                            {
                                ZoneCheck(_cInfo, _player);
                            }
                        }
                    }
                }
            }
            if (!DP)
            {
                _counter++;
                if (_counter >= 6)
                {
                    _counter = 0;
                    for (int i = 0; i < _playerList.Count; i++)
                    {
                        EntityPlayer _player = _playerList[i];
                        if (_player != null)
                        {
                            _player.ClearDamagedTarget();
                        }
                    }
                }
            }
            else
            {
                _counter = 0;
            }
        }
Example #2
0
        public static void Exec()
        {
            DP = false;
            List <EntityPlayer> _playerList = GameManager.Instance.World.Players.list;

            for (int i = 0; i < _playerList.Count; i++)
            {
                EntityPlayer _player = _playerList[i];
                if (_player != null)
                {
                    ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForEntityId(_player.entityId);
                    if (_cInfo != null)
                    {
                        if (_player.IsDead())
                        {
                            DP = true;
                            if (!Dead.Contains(_player.entityId))
                            {
                                Dead.Add(_player.entityId);
                                if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                                {
                                    string _sql = string.Format("UPDATE Players SET eventRespawn = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                                    SQL.FastQuery(_sql);
                                }
                                if (!DeathTime.ContainsKey(_player.entityId))
                                {
                                    Vector3 _position  = _player.GetPosition();
                                    int     x          = (int)_position.x;
                                    int     y          = (int)_position.y;
                                    int     z          = (int)_position.z;
                                    string  _dposition = x + "," + y + "," + z;
                                    DeathTime.Add(_player.entityId, DateTime.Now);
                                    LastDeathPos.Add(_player.entityId, _dposition);
                                }
                                else
                                {
                                    Vector3 _position  = _player.GetPosition();
                                    int     x          = (int)_position.x;
                                    int     y          = (int)_position.y;
                                    int     z          = (int)_position.z;
                                    string  _dposition = x + "," + y + "," + z;
                                    DeathTime[_player.entityId]    = DateTime.Now;
                                    LastDeathPos[_player.entityId] = _dposition;
                                }
                                for (int j = 0; j < _playerList.Count; j++)
                                {
                                    EntityPlayer _player2 = _playerList[j];
                                    Entity       _target  = _player2.GetDamagedTarget();
                                    if (_target == _player && _player != _player2)
                                    {
                                        _player2.ClearDamagedTarget();
                                        ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_player2.entityId);
                                        if (_cInfo != null && _cInfo2 != null)
                                        {
                                            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)
                                            {
                                                if (!_player.IsFriendsWith(_player2) && !_player2.IsFriendsWith(_player))
                                                {
                                                    if (ClanManager.IsEnabled)
                                                    {
                                                        if (ClanManager.ClanMember.Contains(_cInfo.playerId) && ClanManager.ClanMember.Contains(_cInfo2.playerId))
                                                        {
                                                            string    _sql1     = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                                            DataTable _result1  = SQL.TQuery(_sql1);
                                                            string    _clanName = _result1.Rows[0].ItemArray.GetValue(0).ToString();
                                                            _result1.Dispose();
                                                            _sql1 = string.Format("SELECT clanname FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                                                            DataTable _result2   = SQL.TQuery(_sql1);
                                                            string    _clanName2 = _result2.Rows[0].ItemArray.GetValue(0).ToString();
                                                            _result2.Dispose();
                                                            Player p2 = PersistentContainer.Instance.Players[_cInfo2.playerId, false];
                                                            if (_clanName != "Unknown" && _clanName2 != "Unknown")
                                                            {
                                                                if (_clanName == _clanName2)
                                                                {
                                                                    return;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    string    _sql    = string.Format("SELECT bounty, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo.playerId);
                                                    DataTable _result = SQL.TQuery(_sql);
                                                    int       _bounty;
                                                    int       _hunterCountVictim;
                                                    int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _bounty);
                                                    int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountVictim);
                                                    _result.Dispose();
                                                    if (_bounty > 0)
                                                    {
                                                        _sql = string.Format("SELECT playerSpentCoins, bountyHunter FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                                                        DataTable _result2 = SQL.TQuery(_sql);
                                                        int       _playerSpentCoins;
                                                        int       _hunterCountKiller;
                                                        int.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins);
                                                        int.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _hunterCountKiller);
                                                        _result2.Dispose();
                                                        if (Bounties.Bonus > 0 && _hunterCountVictim >= Bounties.Bonus)
                                                        {
                                                            _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty + Bounties.Bonus, _hunterCountKiller + 1, _cInfo2.playerId);
                                                            SQL.FastQuery(_sql);
                                                        }
                                                        else
                                                        {
                                                            _sql = string.Format("UPDATE Players SET playerSpentCoins = {0}, bountyHunter = {1} WHERE steamid = '{2}'", _playerSpentCoins + _bounty, _hunterCountKiller + 1, _cInfo2.playerId);
                                                            SQL.FastQuery(_sql);
                                                        }
                                                        _sql = string.Format("UPDATE Players SET bounty = 0, bountyHunter = 0 WHERE steamid = '{0}'", _cInfo.playerId);
                                                        SQL.FastQuery(_sql);
                                                        string _phrase912;
                                                        if (!Phrases.Dict.TryGetValue(912, out _phrase912))
                                                        {
                                                            _phrase912 = "{PlayerName} is a bounty hunter! {Victim} was snuffed out.";
                                                        }
                                                        _phrase912 = _phrase912.Replace("{PlayerName}", _cInfo2.playerName);
                                                        _phrase912 = _phrase912.Replace("{Victim}", _cInfo.playerName);
                                                        ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase912, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                                        using (StreamWriter sw = new StreamWriter(filepath, true))
                                                        {
                                                            sw.WriteLine(string.Format("{0}: {1} is a bounty hunter! {2} was snuffed out. Bounty was worth {3}", DateTime.Now, _cInfo2.playerName, _cInfo.playerName, _bounty));
                                                            sw.WriteLine();
                                                            sw.Flush();
                                                            sw.Close();
                                                        }
                                                    }
                                                    if (Bounties.Kill_Streak > 0)
                                                    {
                                                        if (KillStreak.ContainsKey(_cInfo.entityId))
                                                        {
                                                            KillStreak.Remove(_cInfo.entityId);
                                                            using (StreamWriter sw = new StreamWriter(filepath, true))
                                                            {
                                                                sw.WriteLine(string.Format("{0}: Player {1} kill streak has come to an end by {2}.", DateTime.Now, _cInfo.playerName, _cInfo2.playerName));
                                                                sw.WriteLine();
                                                                sw.Flush();
                                                                sw.Close();
                                                            }
                                                        }
                                                        if (KillStreak.ContainsKey(_cInfo2.entityId))
                                                        {
                                                            int _value;
                                                            if (KillStreak.TryGetValue(_cInfo2.entityId, out _value))
                                                            {
                                                                int _newValue = _value + 1;
                                                                KillStreak[_cInfo2.entityId] = _newValue;
                                                                if (_newValue == Bounties.Kill_Streak)
                                                                {
                                                                    string _phrase913;
                                                                    if (!Phrases.Dict.TryGetValue(913, out _phrase913))
                                                                    {
                                                                        _phrase913 = "{PlayerName} is on a kill streak! Their bounty has increased.";
                                                                    }
                                                                    _phrase913 = _phrase913.Replace("{PlayerName}", _cInfo2.playerName);
                                                                    ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase913, -1, LoadConfig.Server_Response_Name, EChatType.Global, null);
                                                                }
                                                                if (_newValue >= Bounties.Kill_Streak)
                                                                {
                                                                    _sql = string.Format("SELECT bounty FROM Players WHERE steamid = '{0}'", _cInfo2.playerId);
                                                                    DataTable _result3 = SQL.TQuery(_sql);
                                                                    int       _oldBounty;
                                                                    int.TryParse(_result3.Rows[0].ItemArray.GetValue(0).ToString(), out _oldBounty);
                                                                    _result3.Dispose();
                                                                    _sql = string.Format("UPDATE Players SET bounty = {0} WHERE steamid = '{1}'", _oldBounty + Bounties.Bonus, _cInfo.playerId);
                                                                    SQL.FastQuery(_sql);
                                                                    using (StreamWriter sw = new StreamWriter(filepath, true))
                                                                    {
                                                                        sw.WriteLine(string.Format("{0}: {1} is on a kill streak of {2}. Their bounty has increased.", DateTime.Now, _cInfo2.playerName, _newValue));
                                                                        sw.WriteLine();
                                                                        sw.Flush();
                                                                        sw.Close();
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            KillStreak.Add(_cInfo2.entityId, 1);
                                                        }
                                                    }
                                                }
                                            }
                                            if (Zones.IsEnabled)
                                            {
                                                Zones.Check(_cInfo2, _cInfo);
                                            }
                                        }
                                    }
                                }
                                if (Wallet.IsEnabled && Wallet.Lose_On_Death)
                                {
                                    World     world   = GameManager.Instance.World;
                                    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);
                                    }
                                }
                                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);
                                }
                            }
                        }
                        else
                        {
                            if (Zones.IsEnabled)
                            {
                                ZoneCheck(_cInfo, _player);
                            }
                        }
                    }
                }
            }
            if (!DP)
            {
                _counter++;
                if (_counter >= 6)
                {
                    _counter = 0;
                    for (int i = 0; i < _playerList.Count; i++)
                    {
                        EntityPlayer _player = _playerList[i];
                        if (_player != null)
                        {
                            _player.ClearDamagedTarget();
                        }
                    }
                }
            }
            else
            {
                _counter = 0;
            }
        }