PlayerState Info

A plugin by thommie

PlayerState Info
Downloads 11,176
Updated 1 year ago
Released 3 years ago
Created 3 years ago
Numeric ID 191
Signed
Game Trackmania

NOTE: this plugin is for developers only

This plugin gives easy access to information from the player so you don't have to get all the data yourself. The data is mostly collected using the following classes:

  • CGamePlayground
  • CTrackManiaNetworkServerInfo
  • CGameCtnChallenge
  • CSmArenaClient
  • CSmScriptPlayer
  • CSmPlayer

Please report any issues or provide suggestions here: https://github.com/thommie-echo/TMNext-PlayerState

Usage:

PlayerState::sTMData@ TMData = PlayerState::GetRaceData();
if(TMData.dEventInfo.FinishRun)
  print("Finished at: " + TMData.dPlayerInfo.EndTime);

This then gives access to the following (available both in single and multiplayer).

within TMData:

  • Enum PlayerState (Menus, Countdown, Driving, EndRace, Finished, Spectating, InEditor)
  • bool IsPaused
  • bool IsMultiplayer
  • bool IsSpectator
  • and the following subclasses (only when the PlayerState is not Menus or InEditor)

.dEventInfo

  • bool EndRun // True if the run of the player ends, either manually or by finishing
  • bool FinishRun // Will coincide with EndRun, true the first tick when the player passes through the finish
  • bool MapChange // True when changing a map, either from menu or a previous map
  • bool PauseChange // True when 'escape'-menu is open, only actually paused in singleplayer
  • bool PlayerStateChange; // True when the PlayerState changes compared to the previous state
  • bool ServerChange // True when a server is joined
  • bool GameModeChange // True when the gamemode has changed
  • bool HandicapChange // True when any of the handicaps from dPlayerInfo change
  • bool CheckpointChange // True when the player passes through a checkpoint, or if the run is ended
  • bool LapChange // True when the player has just started a new lap (can also be the first lap)
  • bool bRespawned // True when the player has just respawned a checkpoint
  • bool bRespawnChange // True when the player has just started or ended the respawn

.dServerInfo

  • int PlayerCount
  • string ServerName
  • string ServerLogin
  • string CurGameModeStr // Current gamemode

.dMapInfo

  • string MapName
  • string AuthorLogin
  • string AuthorNickName
  • string MapType
  • string MapStyle
  • uint TMObjective_NbLaps
  • bool TMObjective_IsLapRace
  • uint TMObjective_AuthorTime
  • uint TMObjective_GoldTime
  • uint TMObjective_SilverTime
  • uint TMObjective_BronzeTime
  • int NumberOfCheckpoints
  • bool bIsMultiLap

.dPlayerInfo

  • int EndTime // End time of the current run, see also IsFinish to see whether the time is a result of a finish or a reset

  • uint RaceWaypointTimes // Array of checkpoint times of the player

  • uint NumberOfCheckpointsPassed // This is actually the same as the length of RaceWaypointTimes

  • uint CurrentLapNumber

  • int CurrentRaceTime

  • int LapStartTime

  • uint LatestCPTime // The time of the latest CP passed by the player

  • uint RespawnTime

  • uint NbRespawnsRequested

  • int StartTime // CSmPlayer.ScriptAPI; in GameTime

  • vec3 Position // CSmPlayer.ScriptAPI

  • float AimYaw // CSmPlayer.ScriptAPI

  • float AimPitch // CSmPlayer.ScriptAPI

  • vec3 AimDirection // CSmPlayer.ScriptAPI

  • vec3 Velocity // CSmPlayer.ScriptAPI

  • float Speed // CSmPlayer.ScriptAPI

  • string Login // CSmPlayer.ScriptAPI

  • string Name // CSmPlayer.ScriptAPI

  • int LatestCheckpointLandmarkIndex // CSmPlayer; starts at the maximum number of checkpoints + finish + start, after first cp goes to 0 and up from there

Changelog

1.3.1 - 1 year ago

Updated to include exported dependencies.

1.3.0 - 2 years ago

Breaking changes:

  • sMLData.PlayerData and sMLData.AllPlayerData no longer work, please create an issue if you were using this.
  • Now requires MLHook and MLFeedRaceData

This should fix the game crashing when playing COTD and the game slowing down after playing for a long time or on large servers.

1.2.0 - 2 years ago

  • Fixed linked checkpoints being counted double (Greep)
  • Fixed respawn detection not working correctly on multiple respawns before timer runs out
  • Added dPlayerInfo.RespawnType (ERespawnType_None, Running, Standing) enum to determine what type of respawn the player is on (this ignores the fact that it's possible to do multiple standing respawns before the timer runs out)

View all changelogs