Fix APIcalls

This commit is contained in:
Dork Normalize 2025-03-28 00:37:15 -07:00
parent a08de59a73
commit c6e6a7e6bd
3 changed files with 23 additions and 5 deletions

View file

@ -147,6 +147,11 @@ public partial class HomePage : UserControl
}
};
// Vehicle Destruction
TrackREventDispatcher.VehicleDestructionEvent += (data) => {
LocalPlayerData.LastSeenVehicleLocation = data.VehicleZone;
};
_UIEventsRegistered = true;
}

View file

@ -29,7 +29,7 @@ public class LogHandler(string logPath)
new InstancedInteriorEvent(),
new InArenaCommanderEvent(),
new InPersistentUniverseEvent(),
new GameVersionEvent(),
new GameVersionEvent()
];
// Initialize the LogHandler and run all startup handlers

View file

@ -51,7 +51,7 @@ public static class WebHandler
var ueeMatch = ueePattern.Match(content);
if (ueeMatch.Success)
{
playerData.UEERecord = ueeMatch.Groups[1].Value;
playerData.UEERecord = ueeMatch.Groups[1].Value == "n/a" ? "-1" : ueeMatch.Groups[1].Value;
}
var orgMatch = orgPattern.Match(content);
@ -88,15 +88,28 @@ public static class WebHandler
rsi = enemyPlayerData?.UEERecord,
weapon = deathData.Weapon,
method = deathData.DamageType,
// loadout_ship = LocalPlayerData.PlayerShip ?? "Unknown",
loadout_ship = LocalPlayerData.PlayerShip ?? "Unknown",
game_version = LocalPlayerData.GameVersion ?? "Unknown",
gamemode = LocalPlayerData.CurrentGameMode.ToString() ?? "Unknown",
trackr_version = UpdatePage.currentVersion ?? "Unknown",
trackr_version = UpdatePage.currentVersion.Replace("v", "") ?? "Unknown",
location = LocalPlayerData.LastSeenVehicleLocation ?? "Unknown"
};
switch (LocalPlayerData.CurrentGameMode)
{
case GameMode.PersistentUniverse:
killData.gamemode = "pu";
break;
case GameMode.ArenaCommander:
killData.gamemode = "ac";
break;
}
var httpClient = new HttpClient();
string jsonData = JsonSerializer.Serialize(killData);
await httpClient.PostAsync(ConfigManager.ApiUrl + "/register-kill", new StringContent(jsonData, Encoding.UTF8, "application/json"));
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + ConfigManager.ApiKey);
httpClient.DefaultRequestHeaders.Add("User-Agent", "AutoTrackR2");
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
await httpClient.PostAsync(ConfigManager.ApiUrl + "register-kill", new StringContent(jsonData, Encoding.UTF8, "application/json"));
}
}