Esempio n. 1
0
        private void PrintKillLabel(PlayerCache playerCache)
        {
            // Print some simple kill stats to player and all when at certain threshold

            // Did player kill someone?
            if (playerCache.LastPlayerDelta.Score.Kills < 1)
            {
                return;
            }


            var historyItems = new List <PlayerHistoryItem>(GetHistory(playerCache, _killPeriodLookbehind));

            if (historyItems.Count() == 0)
            {
                return;
            }

            if (_lookingForFirstKill)
            {
                _lookingForFirstKill = false;
                _rconClient.SendMessageAll("KD: First kill: " + playerCache.Player.Name + " in " + _rconClient.ServerInfoCommand.ServerInfo.ElapsedRoundTime + " seconds.");
            }

            int               kills        = 0;
            DateTime          oldestUpdate = default(DateTime);
            PlayerHistoryItem lastWithKill = null;

            foreach (var historyItem in historyItems)
            {
                kills += historyItem.PlayerDelta.Score.Kills;
                if (historyItem.PlayerDelta.Score.Kills > 0)
                {
                    lastWithKill = historyItem;
                }
            }
            // Last kill watch
            if (lastWithKill != null)
            {
                oldestUpdate = lastWithKill.Player.LastUpdate;
                _lastKills.Enqueue(lastWithKill);
            }
            // Last kill queue length limit
            while (_lastKills.Count > _lastkillsLength)
            {
                _lastKills.Dequeue();
            }

            var timeSinceOldest = DateTime.Now.Subtract(oldestUpdate);

            // Message player
            if (kills >= _reportKillsToPersonAt && !playerCache.Settings.StopSpam)
            {
                _rconClient.SendMessagePlayer(playerCache.Player, "KD: Last " + (int)timeSinceOldest.TotalSeconds + " seconds: " + kills + " kills.");
            }
            if (kills >= _reportKillsToAllAt)
            {
                _rconClient.SendMessageAll("KD: " + playerCache.Player.Name + " has " + kills + " kills in just " + (int)timeSinceOldest.TotalSeconds + " seconds.");
            }
        }
Esempio n. 2
0
        private void PrintDeathLabel(PlayerCache playerCache)
        {
            // Print some simple Death stats to player and all when at certain threshold

            // Did player Death someone?
            if (playerCache.LastPlayerDelta.Score.Deaths < 1)
            {
                return;
            }


            var historyItems = new List <PlayerHistoryItem>(GetHistory(playerCache, _deathPeriodLookbehind));

            if (historyItems.Count() == 0)
            {
                return;
            }

            if (_lookingForFirstDeath)
            {
                _lookingForFirstDeath = false;
                _rconClient.SendMessageAll("KD: First Death: " + playerCache.Player.Name);
            }

            int               deaths        = 0;
            DateTime          oldestUpdate  = default(DateTime);
            PlayerHistoryItem lastWithDeath = null;

            foreach (var historyItem in historyItems)
            {
                deaths += historyItem.PlayerDelta.Score.Deaths;
                if (historyItem.PlayerDelta.Score.Deaths > 0)
                {
                    lastWithDeath = historyItem;
                }
            }
            // Last Death watch
            if (lastWithDeath != null)
            {
                oldestUpdate = lastWithDeath.Player.LastUpdate;
                _lastDeaths.Enqueue(lastWithDeath);
            }
            // Last Death queue length limit
            while (_lastDeaths.Count > _lastDeathsLength)
            {
                _lastDeaths.Dequeue();
            }

            var timeSinceOldest = DateTime.Now.Subtract(oldestUpdate);

            // Message player
            if (deaths > 1 && !playerCache.Settings.StopSpam)
            {
                _rconClient.SendMessagePlayer(playerCache.Player,
                                              "KD: Last " + (int)timeSinceOldest.TotalSeconds + " seconds: " + deaths +
                                              " deaths.");
            }
            if (deaths > 3)
            {
                _rconClient.SendMessageAll("KD: " + playerCache.Player.Name + " has " + deaths + " deaths in just " + (int)timeSinceOldest.TotalSeconds + " seconds.");
            }
        }