MLFeed: Race Data

A plugin by XertroV(Trusted developer)

MLFeed: Race Data
Downloads 77,724
Updated 9 days ago
Released 3 years ago
Created 3 years ago
Numeric ID 255
Min. Openplanet 1.26.0
Game Trackmania

MLFeed: Race Data

This plugin provides other plugins with data about the current race. You might need to install it to make other plugins work.

Requires MLHook (you need to install that plugin too)

Please report performance issues! See bottom of page for who/where.

For Developers

Currently exposed data:

  • Sorted Player data
    • For each player: LatestCPTime, CPCount, Cached Previous CP Times, Spawn Status, Best Time, Best CP Times, Best Lap Times, Time Lost to Respawns (in total and per CP), NbRespawns
    • Sort methods
      • TimeAttack: sort by best time
      • Race: sorted by race leader
      • Race_Respawns: sorted by race leader, but updates ranking immediately when a player respawns to account for time-loss
  • Knockout data (for COTD / KO)
    • Per-Player Alive and DNF status
    • Total Rounds, Current Round, Alive Players, Number of KOs This Round, Next KO Milestone, Number of Players (originally)
  • The last record set by the current player
  • Ghost Data
    • Which ghosts have been loaded, the name of the ghost, and the ghost's checkpoint times.

Additional data exposure available upon request.

Using MLFeed: Race Data

Some plugins already using MLFeed:

Importing to your plugin

Include this in your info.toml file:

[script]
dependencies = ["MLHook", "MLFeedRaceData"] # need both

see also: https://openplanet.dev/docs/reference/info-toml

Usage: Getting started

Note: it is recommended that you use the Openplanet VSCode extension which will provide autocompletion and documentation for you when using MLFeed.

Main Entry Points

Several feeds are available that provide different information. The functions that provide the feeds are:

  • auto RaceData = MLFeed::GetRaceData_V4()
  • auto KoData = MLFeed::GetKoData() -- for knockout mode (including COTD KO)
  • auto GhostData = MLFeed::GetGhostData() -- info about loaded ghosts
  • auto MMData = MLFeed::GetTeamsMMData_V1() -- info about matchmaking
  • auto MapListUids = MLFeed::Get_MapListUids_Receiver() -- info about the server map list

The main info for players can be accessed via the sorted RaceData lists, getting via name, or getting via login:

  • auto player = RaceData.GetPlayer_V4(name)
  • auto player = RaceData.GetPlayer_V4_ByLogin(login)
  • auto leadInRace = cast<MLFeed::PlayerCpInfo_V4>(RaceData.SortedPlayers_Race[0])
  • auto leadInRace = cast<MLFeed::PlayerCpInfo_V4>(RaceData.SortedPlayers_RaceRespawns[0])
  • auto leadInTA = cast<MLFeed::PlayerCpInfo_V4>(RaceData.SortedPlayers_TimeAttack[0])

Note: all player classes can be cast to MLFeed::PlayerCpInfo_V4 -- the sorted arrays contain MLFeed::PlayerCpInfo_V2 for historical reasons.

PlayerCpInfo contains checkpoint and race data, respawn info, and a bunch of other useful info.

Full docs can be found in the export files:

Race Data Example

Main type: HookRaceStatsEventsBase_V4

Example usage: doing something on player respawn.

uint lastRespawnCount = 0;

void Update(float dt) {
    if (GetApp().CurrentPlayground is null) return;
    // Get race data and the local player
    auto RaceData = MLFeed::GetRaceData_V4();
    auto player = RaceData.GetPlayer_V4(MLFeed::LocalPlayersName);
    if (player is null) return;
    // check for respawns
    if (player.NbRespawnsRequested != lastRespawnCount) {
        lastRespawnCount = player.NbRespawnsRequested;
        if (lastRespawnCount != 0) {
            startnew(OnPlayerRespawn);
        }
    }
}

void OnPlayerRespawn() {
    // do stuff
}

Docs at end

Usage: See Also

The Demo UIs available in (openplanet's) developer mode (via Scripts menu) & associated source code in the repo.

Exported functions (https://github.com/XertroV/tm-mlfeed-race-data/blob/manialink-base/src/MLFeed_Export.as)

Exported classes (https://github.com/XertroV/tm-mlfeed-race-data/blob/manialink-base/src/MLFeed_ExportShared.as)

Example Usage - COTD Buffer Time

Example Usage - Race Stats

Example Optional Usage - List Players' PBs

Still curious about how to use something? Read the examples and use github search to find usages! Still not sure? Ask @XertroV on the Openplanet Discord

Boring Stuff

License: Public Domain

Authors: XertroV

Suggestions/feedback: @XertroV on Openplanet discord

Code/issues: https://github.com/XertroV/tm-mlfeed-race-data

GL HF

Changelog

0.6.3 - 9 days ago

Fix rare script error on Score.User null

0.6.2 - 6 months ago

  • Fix const on PlayersLeftThisBatch and friends
  • Fix edge case sorting unspawned players with race ranking
  • Fix spawn counter and spawn index so spawn indexes are the same for players spawning on the same frame

0.6.1 - 6 months ago

  • Fix ML exception in ShouldUpdatePlayers

View all changelogs