Example #1
0
        public override void Added()
        {
            base.Added();

            string trackerApiSettingsFile = Path.Combine(GetSavePath(), "tf-tracker-api.txt");

            if (File.Exists(trackerApiSettingsFile))
            {
                string[] trackerApiSettings = File.ReadAllLines(trackerApiSettingsFile);
                if (trackerApiSettings.Length < 2)
                {
                    TFGame.Log(new Exception("Invalid tf-tracker-api.txt contents"), false);
                    return;
                }
                string            apiUrl = trackerApiSettings[0];
                string            apiKey = trackerApiSettings[1];
                TrackerMatchStats stats  = new TrackerMatchStats();

                stats.rounds = ((MySession)this.session).RoundsPlayedThisMatch;
                for (int index = 0; index < this.session.MatchStats.Length; index++)
                {
                    if (TFGame.Players[index])
                    {
                        stats.kills[index]  = (int)this.session.MatchStats[index].Kills.Kills;
                        stats.deaths[index] =
                            (int)this.session.MatchStats[index].Deaths.Kills +
                            (int)this.session.MatchStats[index].Deaths.SelfKills +
                            (int)this.session.MatchStats[index].Deaths.TeamKills;
                        stats.wins[index]      = this.session.MatchStats[index].Won ? 1 : 0;
                        stats.selfs[index]     = (int)this.session.MatchStats[index].Kills.SelfKills;
                        stats.teamKills[index] = (int)this.session.MatchStats[index].Kills.TeamKills;
                        stats.revives[index]   = (int)this.session.MatchStats[index].Revives;
                    }
                }

                string payload = stats.ToJSON(apiKey).Replace("\"", "\\\"");

                Process.Start(
                    "/bin/bash",
                    "-c \"curl '" + apiUrl + "matches' " +
                    "-X POST -H 'Content-Type: application/json' -H 'Accept: application/json' " +
                    "--data-binary '" + payload + "' --compressed\""
                    );
            }
        }
Example #2
0
        public void OnPlayerGhostDeath(PlayerGhost ghost, PlayerCorpse corpse)
        {
            String logicName = this.RoundLogic.GetType().Name;

            TFGame.Log(new Exception(logicName), false);
            switch (logicName)
            {
            case "TeamDeathmatchRoundLogic":
                ((MyTeamDeathmatchRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse);
                break;

            case "HeadhuntersRoundLogic":
                ((MyHeadhuntersRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse);
                break;

            case "LastManStandingRoundLogic":
                ((MyLastManStandingRoundLogic)this.RoundLogic).OnPlayerGhostDeath(ghost, corpse);
                break;
            }
        }
Example #3
0
 private static void LogException(Exception exception, bool isOnLoad)
 {
     TFGame.WriteLineToLoadLog(CreateMessageString(exception.Message, true));
     TFGame.Log(exception, isOnLoad);
     Console.WriteLine($"{CreateMessageString(exception.Message, true)}");
 }
Example #4
0
 private static void RespCallback(IAsyncResult ar)
 {
     TFGame.Log(new Exception("Result Callback"), false);
 }