예제 #1
0
 public static bool BattleLog(ClientInfo _cInfo)
 {
     try
     {
         EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId);
         if (_player != null)
         {
             List <EntityPlayer> _players = PersistentOperations.PlayerList();
             if (_players != null)
             {
                 for (int i = 0; i < _players.Count; i++)
                 {
                     EntityPlayer _player2 = _players[i];
                     if (_player2 != null && _player2 != _player)
                     {
                         EntityPlayer _damageTarget  = (EntityPlayer)_player.GetDamagedTarget();
                         EntityPlayer _attackTarget  = (EntityPlayer)_player.GetAttackTarget();
                         EntityPlayer _damageTarget2 = (EntityPlayer)_player2.GetDamagedTarget();
                         EntityPlayer _attackTarget2 = (EntityPlayer)_player2.GetAttackTarget();
                         if ((_damageTarget != null && _damageTarget == _player2 && !_damageTarget.IsFriendsWith(_player2)) ||
                             (_attackTarget != null && _attackTarget == _player2 && !_attackTarget.IsFriendsWith(_player2)) ||
                             (_damageTarget2 != null && _damageTarget2 == _player && !_damageTarget2.IsFriendsWith(_player)) ||
                             (_attackTarget2 != null && _attackTarget2 == _player && !_damageTarget2.IsFriendsWith(_player)))
                         {
                             float _distance = _player2.GetDistanceSq(_player);
                             if (_distance <= 80f)
                             {
                                 Timers.BattleLogTool(_cInfo.playerId);
                             }
                         }
                     }
                 }
             }
         }
         BattleLogger.Players.Remove(_cInfo.playerId);
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.BattleLog: {0}.", e.Message));
     }
     return(true);
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
        public static void Check()
        {
            List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients();

            for (int i = 0; i < _cInfoList.Count; i++)
            {
                ClientInfo   _cInfoKiller = _cInfoList[i];
                EntityPlayer _player      = GameManager.Instance.World.Players.dict[_cInfoKiller.entityId];
                int          _playerKills = _player.KilledPlayers;
                if (!PlayerKills.ContainsKey(_cInfoKiller.entityId))
                {
                    PlayerKills[_cInfoKiller.entityId] = _playerKills;
                }
                else
                {
                    int _kills;
                    if (PlayerKills.TryGetValue(_cInfoKiller.entityId, out _kills))
                    {
                        if (_playerKills > _kills)
                        {
                            PlayerKills[_cInfoKiller.entityId] = _playerKills;
                            var _victim = _player.GetDamagedTarget();
                            if (_victim != null && _cInfoKiller.entityId != _victim.entityId)
                            {
                                ClientInfo _cInfoVictim = ConnectionManager.Instance.GetClientInfoForEntityId(_victim.entityId);
                                if (_cInfoVictim != null)
                                {
                                    if (PvEFlag.ContainsKey(_cInfoVictim.entityId) & PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                    {
                                        string _phrase801;
                                        if (!Phrases.Dict.TryGetValue(801, out _phrase801))
                                        {
                                            _phrase801 = "{Killer} has murdered you while you were in a protected zone.";
                                        }
                                        _phrase801 = _phrase801.Replace("{Killer}", _cInfoKiller.playerName);
                                        _cInfoVictim.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase801), Config.Server_Response_Name, false, "ServerTools", false));
                                        string _phrase802;
                                        if (!Phrases.Dict.TryGetValue(802, out _phrase802))
                                        {
                                            _phrase802 = "You have murdered a player inside a protected zone. Their name was {Victim}";
                                        }
                                        _phrase802 = _phrase802.Replace("{Victim}", _cInfoVictim.playerName);
                                        _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase802), Config.Server_Response_Name, false, "ServerTools", false));
                                        Penalty(_cInfoKiller, _cInfoVictim);
                                        Victim[_cInfoVictim.entityId] = _victim.position;
                                        continue;
                                    }
                                    if (PvEFlag.ContainsKey(_cInfoVictim.entityId) & !PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                    {
                                        string _phrase801;
                                        if (!Phrases.Dict.TryGetValue(801, out _phrase801))
                                        {
                                            _phrase801 = "{Killer} has murdered you while you were in a protected zone.";
                                        }
                                        _phrase801 = _phrase801.Replace("{Killer}", _cInfoKiller.playerName);
                                        _cInfoVictim.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase801), Config.Server_Response_Name, false, "ServerTools", false));
                                        string _phrase802;
                                        if (!Phrases.Dict.TryGetValue(802, out _phrase802))
                                        {
                                            _phrase802 = "You have murdered a player inside a protected zone. Their name was {Victim}";
                                        }
                                        _phrase802 = _phrase802.Replace("{Victim}", _cInfoVictim.playerName);
                                        _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase802), Config.Server_Response_Name, false, "ServerTools", false));
                                        Penalty(_cInfoKiller, _cInfoVictim);
                                        Victim[_cInfoVictim.entityId] = _victim.position;
                                        continue;
                                    }
                                    if (!PvEFlag.ContainsKey(_cInfoVictim.entityId) & PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                    {
                                        string _phrase803;
                                        if (!Phrases.Dict.TryGetValue(801, out _phrase803))
                                        {
                                            _phrase803 = "{Killer} has murdered you while they were in a protected zone.";
                                        }
                                        _phrase803 = _phrase803.Replace("{Killer}", _cInfoKiller.playerName);
                                        _cInfoVictim.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase803), Config.Server_Response_Name, false, "ServerTools", false));
                                        string _phrase802;
                                        if (!Phrases.Dict.TryGetValue(802, out _phrase802))
                                        {
                                            _phrase802 = "You have murdered a player inside a protected zone. Their name was {Victim}";
                                        }
                                        _phrase802 = _phrase802.Replace("{Victim}", _cInfoVictim.playerName);
                                        _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase802), Config.Server_Response_Name, false, "ServerTools", false));
                                        Penalty(_cInfoKiller, _cInfoVictim);
                                        Victim[_cInfoVictim.entityId] = _victim.position;
                                        string _file1     = string.Format("DetectionLog_{0}.txt", DateTime.Today.ToString("M-d-yyyy"));
                                        string _filepath1 = string.Format("{0}/DetectionLogs/{1}", API.GamePath, _file1);
                                        using (StreamWriter sw = new StreamWriter(_filepath1, true))
                                        {
                                            sw.WriteLine(string.Format("Detected {0}, Steam Id {1}, murdered {2}, Steam Id {3} in a protected zone.", _cInfoKiller.playerName, _cInfoKiller.steamId, _cInfoVictim.playerName, _cInfoVictim.steamId));
                                            sw.WriteLine();
                                            sw.Flush();
                                            sw.Close();
                                        }
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                }
                if (!_player.IsDead())
                {
                    int _X = (int)_player.position.x;
                    int _Y = (int)_player.position.y;
                    int _Z = (int)_player.position.z;
                    if (Box.Count > 0)
                    {
                        Flag.Remove(_cInfoKiller.entityId);
                        foreach (KeyValuePair <string, string[]> kvpCorners in Box)
                        {
                            float    xMin;
                            float    yMin;
                            float    zMin;
                            string[] _corner1 = kvpCorners.Value[0].Split(',');
                            float.TryParse(_corner1[0], out xMin);
                            float.TryParse(_corner1[1], out yMin);
                            float.TryParse(_corner1[2], out zMin);
                            float    xMax;
                            float    yMax;
                            float    zMax;
                            string[] _corner2 = kvpCorners.Value[1].Split(',');
                            float.TryParse(_corner2[0], out xMax);
                            float.TryParse(_corner2[1], out yMax);
                            float.TryParse(_corner2[2], out zMax);
                            if (xMin >= 0 & xMax >= 0)
                            {
                                if (xMin < xMax)
                                {
                                    if (_X >= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_X <= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_X <= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_X >= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                            }
                            else if (xMin <= 0 & xMax <= 0)
                            {
                                if (xMin < xMax)
                                {
                                    if (_X >= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_X <= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_X <= xMin)
                                    {
                                        _xMinCheck = 1;
                                    }
                                    else
                                    {
                                        _xMinCheck = 0;
                                    }
                                    if (_X >= xMax)
                                    {
                                        _xMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _xMaxCheck = 0;
                                    }
                                }
                            }
                            else if (xMin <= 0 & xMax >= 0)
                            {
                                if (_X >= xMin)
                                {
                                    _xMinCheck = 1;
                                }
                                else
                                {
                                    _xMinCheck = 0;
                                }
                                if (_X <= xMax)
                                {
                                    _xMaxCheck = 1;
                                }
                                else
                                {
                                    _xMaxCheck = 0;
                                }
                            }
                            else if (xMin >= 0 & xMax <= 0)
                            {
                                if (_X <= xMin)
                                {
                                    _xMinCheck = 1;
                                }
                                else
                                {
                                    _xMinCheck = 0;
                                }
                                if (_X >= xMax)
                                {
                                    _xMaxCheck = 1;
                                }
                                else
                                {
                                    _xMaxCheck = 0;
                                }
                            }

                            if (yMin >= 0 & yMax >= 0)
                            {
                                if (yMin < yMax)
                                {
                                    if (_Y >= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_Y <= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_Y <= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_Y >= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                            }
                            else if (yMin <= 0 & yMax <= 0)
                            {
                                if (yMin < yMax)
                                {
                                    if (_Y >= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_Y <= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_Y <= yMin)
                                    {
                                        _yMinCheck = 1;
                                    }
                                    else
                                    {
                                        _yMinCheck = 0;
                                    }
                                    if (_Y >= yMax)
                                    {
                                        _yMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _yMaxCheck = 0;
                                    }
                                }
                            }
                            else if (yMin <= 0 & yMax >= 0)
                            {
                                if (_Y >= yMin)
                                {
                                    _yMinCheck = 1;
                                }
                                else
                                {
                                    _yMinCheck = 0;
                                }
                                if (_Y <= yMax)
                                {
                                    _yMaxCheck = 1;
                                }
                                else
                                {
                                    _yMaxCheck = 0;
                                }
                            }
                            else if (yMin >= 0 & yMax <= 0)
                            {
                                if (_Y <= yMin)
                                {
                                    _yMinCheck = 1;
                                }
                                else
                                {
                                    _yMinCheck = 0;
                                }
                                if (_Y >= yMax)
                                {
                                    _yMaxCheck = 1;
                                }
                                else
                                {
                                    _yMaxCheck = 0;
                                }
                            }

                            if (zMin >= 0 & zMax >= 0)
                            {
                                if (zMin < zMax)
                                {
                                    if (_Z >= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_Z <= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_Z <= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_Z >= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                            }
                            else if (zMin <= 0 & zMax <= 0)
                            {
                                if (zMin < zMax)
                                {
                                    if (_Z >= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_Z <= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                                else
                                {
                                    if (_Z <= zMin)
                                    {
                                        _zMinCheck = 1;
                                    }
                                    else
                                    {
                                        _zMinCheck = 0;
                                    }
                                    if (_Z >= zMax)
                                    {
                                        _zMaxCheck = 1;
                                    }
                                    else
                                    {
                                        _zMaxCheck = 0;
                                    }
                                }
                            }
                            else if (zMin <= 0 & zMax >= 0)
                            {
                                if (_Z >= zMin)
                                {
                                    _zMinCheck = 1;
                                }
                                else
                                {
                                    _zMinCheck = 0;
                                }
                                if (_Z <= zMax)
                                {
                                    _zMaxCheck = 1;
                                }
                                else
                                {
                                    _zMaxCheck = 0;
                                }
                            }
                            else if (zMin >= 0 & zMax <= 0)
                            {
                                if (_Z <= zMin)
                                {
                                    _zMinCheck = 1;
                                }
                                else
                                {
                                    _zMinCheck = 0;
                                }
                                if (_Z >= zMax)
                                {
                                    _zMaxCheck = 1;
                                }
                                else
                                {
                                    _zMaxCheck = 0;
                                }
                            }
                            if (_xMinCheck == 1 & _yMinCheck == 1 & _zMinCheck == 1 & _xMaxCheck == 1 & _yMaxCheck == 1 & _zMaxCheck == 1)
                            {
                                if (!PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                {
                                    if (Zone_Message)
                                    {
                                        _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, kvpCorners.Value[2]), Config.Server_Response_Name, false, "ServerTools", false));
                                    }
                                    PvEFlag[_cInfoKiller.entityId] = kvpCorners.Value[3];
                                }
                                else
                                {
                                    string _msg;
                                    if (PvEFlag.TryGetValue(_cInfoKiller.entityId, out _msg))
                                    {
                                        if (_msg != kvpCorners.Value[2])
                                        {
                                            PvEFlag[_cInfoKiller.entityId] = kvpCorners.Value[3];
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (Flag.ContainsKey(_cInfoKiller.entityId))
                                {
                                    int _flag = 0;
                                    if (Flag.TryGetValue(_cInfoKiller.entityId, out _flag))
                                    {
                                        int _flag1 = _flag + 1;
                                        if (_flag1 == Box.Count & PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                        {
                                            if (Zone_Message)
                                            {
                                                string _msg;
                                                if (PvEFlag.TryGetValue(_cInfoKiller.entityId, out _msg))
                                                {
                                                    _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _msg), Config.Server_Response_Name, false, "ServerTools", false));
                                                }
                                            }
                                            PvEFlag.Remove(_cInfoKiller.entityId);
                                        }
                                        else
                                        {
                                            Flag[_cInfoKiller.entityId] = _flag1;
                                        }
                                    }
                                }
                                else
                                {
                                    int _flag = 1;
                                    Flag[_cInfoKiller.entityId] = _flag;
                                    if (_flag == Box.Count & PvEFlag.ContainsKey(_cInfoKiller.entityId))
                                    {
                                        if (Zone_Message)
                                        {
                                            string _msg;
                                            if (PvEFlag.TryGetValue(_cInfoKiller.entityId, out _msg))
                                            {
                                                _cInfoKiller.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _msg), Config.Server_Response_Name, false, "ServerTools", false));
                                            }
                                        }
                                        PvEFlag.Remove(_cInfoKiller.entityId);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #4
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;
            }
        }
예제 #5
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;
            }
        }