Exemple #1
0
        public Task OnEventAsync(GameEvent E, Server S)
        {
            // if it's an IW4 game, with custom callbacks, we want to
            // enable the live radar page
            lock (lockObject)
            {
                if (E.Type == GameEvent.EventType.Start &&
                    S.GameName == Server.Game.IW4 &&
                    S.CustomCallback &&
                    !addedPage)
                {
                    E.Owner.Manager.GetPageList().Pages.Add(Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"], "/Radar/All");
                    addedPage = true;
                }
            }

            if (E.Type == GameEvent.EventType.PreConnect && E.Origin.IsBot)
            {
                string botKey = $"BotGuid_{E.Extra}";
                lock (lockObject)
                {
                    if (!_botGuidLookups.ContainsKey(botKey))
                    {
                        _botGuidLookups.Add(botKey, E.Origin.NetworkId);
                    }
                }
            }

            if (E.Type == GameEvent.EventType.Other && E.Subtype == "LiveRadar")
            {
                try
                {
                    string botKey = $"BotGuid_{E.Extra}";
                    long   generatedBotGuid;

                    lock (lockObject)
                    {
                        generatedBotGuid = _botGuidLookups.ContainsKey(botKey) ? _botGuidLookups[botKey] : 0;
                    }

                    var radarUpdate = RadarEvent.Parse(E.Data, generatedBotGuid);
                    var client      = S.Manager.GetActiveClients().FirstOrDefault(_client => _client.NetworkId == radarUpdate.Guid);

                    if (client != null)
                    {
                        radarUpdate.Name = client.Name.StripColors();
                        client.SetAdditionalProperty("LiveRadar", radarUpdate);
                    }
                }

                catch (Exception e)
                {
                    S.Logger.WriteWarning($"Could not parse live radar output: {e.Data}");
                    S.Logger.WriteDebug(e.GetExceptionInfo());
                }
            }

            return(Task.CompletedTask);
        }
Exemple #2
0
        public static RadarEvent Parse(string input, long generatedBotGuid)
        {
            var items = input.Split(';').Skip(1).ToList();

            var parsedEvent = new RadarEvent()
            {
                Guid       = generatedBotGuid,
                Location   = Vector3.Parse(items[1]),
                ViewAngles = Vector3.Parse(items[2]).FixIW4Angles(),
                Team       = items[3],
                Kills      = int.Parse(items[4]),
                Deaths     = int.Parse(items[5]),
                Score      = int.Parse(items[6]),
                Weapon     = items[7],
                Health     = int.Parse(items[8]),
                IsAlive    = items[9] == "1",
                PlayTime   = Convert.ToInt32(items[10])
            };

            return(parsedEvent);
        }