Ejemplo n.º 1
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;
     }
 }
Ejemplo n.º 2
0
 private static bool GameMessage(ClientInfo _cInfo, EnumGameMessages _type, string _msg, string _mainName, bool _localizeMain, string _secondaryName, bool _localizeSecondary)
 {
     try
     {
         if (_type == EnumGameMessages.EntityWasKilled && _cInfo != null)
         {
             EntityPlayer _player1 = GameManager.Instance.World.Players.dict[_cInfo.entityId];
             if (_player1 != null)
             {
                 bool _notice = false;
                 if (!string.IsNullOrEmpty(_secondaryName) && _mainName != _secondaryName)
                 {
                     ClientInfo _cInfo2 = ConsoleHelper.ParseParamIdOrName(_secondaryName);
                     if (_cInfo2 != null)
                     {
                         EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId];
                         if (_player2 != null)
                         {
                             if (KillNotice.IsEnabled && _player2.IsAlive())
                             {
                                 string _holdingItem = _player2.inventory.holdingItem.Name;
                                 if (!string.IsNullOrEmpty(_holdingItem))
                                 {
                                     ItemValue _itemValue = ItemClass.GetItem(_holdingItem, true);
                                     if (_itemValue.type != ItemValue.None.type)
                                     {
                                         _holdingItem = _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.GetItemName();
                                         KillNotice.Notice(_cInfo, _cInfo2, _holdingItem);
                                         _notice = true;
                                     }
                                 }
                             }
                             if (Zones.IsEnabled)
                             {
                                 Zones.Check(_cInfo, _cInfo2);
                             }
                             if (Bounties.IsEnabled)
                             {
                                 Bounties.PlayerKilled(_player1, _player2, _cInfo, _cInfo2);
                             }
                             if (Wallet.IsEnabled)
                             {
                                 if (Wallet.PVP && Wallet.Player_Kills > 0)
                                 {
                                     Wallet.AddCoinsToWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                                 else if (Wallet.Player_Kills > 0)
                                 {
                                     Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Wallet.Player_Kills);
                                 }
                             }
                         }
                     }
                 }
                 if (DeathSpot.IsEnabled)
                 {
                     DeathSpot.PlayerKilled(_player1);
                 }
                 if (Event.Open && Event.PlayersTeam.ContainsKey(_cInfo.playerId))
                 {
                     string _sql = string.Format("UPDATE Players SET eventReturn = 'true' WHERE steamid = '{0}'", _cInfo.playerId);
                     SQL.FastQuery(_sql, "Players");
                 }
                 if (_notice)
                 {
                     return(false);
                 }
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.GameMessage: {0}.", e.Message));
     }
     return(true);
 }
Ejemplo n.º 3
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;
            }
        }