uniTM API
ITestManagerApi Interface Reference

Detailed Description

Public interface which provides access to uniTM features.

Use this to define custom ranking rules and manage player records.

See the USAGE EXAMPLE for a demonstration of how to use it in an example level.

Public Member Functions

void configureCustomRanking (bool higherIsBetter=true, uint8 recordDisplayFormat=DISPLAYFORMAT::INTEGER, string unitSingular="", string unitPlural="", bool displayTimer=false, int levelCount=0)
 Initializes custom ranking. Configures how custom records are displayed and ranked. Server should run this once in onLevelLoad(). Has no effect when ran by clients.
void getRecordByPlayer (jjPLAYER@ player, PlayerRecordCallback@ callback)
 Retrieves a player's record.
void getRecordByRank (int rank, RankRecordCallback@ callback)
 Retrieves an indexed record.
void getRecordCount (RecordCountCallback@ callback)
 Retrieves the total number of records.
string formatRecord (int record)
 Returns a string representation of a record. Uses the format and units defined in configureCustomRanking().
bool practiceModeEnabled ()
 Checks whether practice mode is enabled.
void disableQuickSuicide ()
 Prevents players from using the "quick suicide" assist tool.
Test state management

Functions for managing a player's test session.

Make sure you understand the 3 player states:

  • Initialized state - represented by an [ini] tag. In this state, the player is not currently playing a test. The timer isn't running and ghost run isn't recording. Certain features such as morphing using !jazz/!spaz/!lori commands are only available in this state. Record submissions will not be accepted. Assign this state any time a player is about to play or restart a test.
  • Level state - represented by a tag with a level number e.g. [5]. Assigning this state indicates the start of a test. Ghost runs and timer can also be enabled. In this state, record submissions are accepted.
  • Win state - represented by a [win] tag Assigning this state indicates the player has finished a test and is no longer playing it.

The following methods are used to transition between the 3 states and can be called both as a server or as a client. Note that a client call can only affect local players.

void initTest (jjPLAYER@ player)
 Initializes a test session and assigns an [ini] tag to a player. Can be used at any time to stop existing test session and prepare for a new run. Serves as a replacement for text events of ID 100. Both approaches are suitable.
void beginTest (jjPLAYER@ player, bool recordGhost=true)
 Begins a test and assigns a level 1 tag [1] to a player. Can only be used on players who are currently wearing an [ini] tag. Serves as a replacement for text events of ID 101. Both approaches are suitable.
void setLevel (jjPLAYER@ player, uint level)
 Updates the level number tag. Can only be used on players that are already in a level state (wearing a level number tag). Cannot be used to begin a test from [ini] state. This is a purely visual change which serves as a replacement of text events with ID range of 102-254.
void finishTest (jjPLAYER@ player, int record, uint8 announceRecord=ANNOUNCERECORD::ALWAYS)
 Ends the test session, submits a record and assigns a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). If applicable, stops the ghost run recording and determines whether to update the ghost run based on provided record value.
void submitRecord (jjPLAYER@ player, int record, uint8 announceRecord=ANNOUNCERECORD::NEVER)
 Submits a record without ending the test session and without assigning a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). Unlike finishTest(), this method should be used when a player reaches a significant milestone in a test, but is still in the game and can continue raising their score. When applicable, the timer will continue running, and ghost run will continue recording.

Member Function Documentation

◆ configureCustomRanking()

void configureCustomRanking ( bool higherIsBetter = true,
uint8 recordDisplayFormat = DISPLAYFORMAT::INTEGER,
string unitSingular = "",
string unitPlural = "",
bool displayTimer = false,
int levelCount = 0 )

Initializes custom ranking. Configures how custom records are displayed and ranked. Server should run this once in onLevelLoad(). Has no effect when ran by clients.

Parameters
higherIsBetterWhether higher record values represent better results.
recordDisplayFormatFormat used when displaying records. See DISPLAYFORMAT.
unitSingularOptional, singular unit name (e.g. "point").
unitPluralOptional, plural unit name (e.g. "points").
displayTimerWhether to display a timer during the test.
levelCountNumber of levels in the test. Leave zero to let uniTM figure it out on its own by scanning the level for text events.

◆ initTest()

void initTest ( jjPLAYER@ player)

Initializes a test session and assigns an [ini] tag to a player. Can be used at any time to stop existing test session and prepare for a new run. Serves as a replacement for text events of ID 100. Both approaches are suitable.

Parameters
playerTarget player.

◆ beginTest()

void beginTest ( jjPLAYER@ player,
bool recordGhost = true )

Begins a test and assigns a level 1 tag [1] to a player. Can only be used on players who are currently wearing an [ini] tag. Serves as a replacement for text events of ID 101. Both approaches are suitable.

Parameters
playerTarget player.
recordGhostDetermines whether a ghost run recording should begin.

◆ setLevel()

void setLevel ( jjPLAYER@ player,
uint level )

Updates the level number tag. Can only be used on players that are already in a level state (wearing a level number tag). Cannot be used to begin a test from [ini] state. This is a purely visual change which serves as a replacement of text events with ID range of 102-254.

Parameters
playerTarget player.
levelLevel number.

◆ finishTest()

void finishTest ( jjPLAYER@ player,
int record,
uint8 announceRecord = ANNOUNCERECORD::ALWAYS )

Ends the test session, submits a record and assigns a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). If applicable, stops the ghost run recording and determines whether to update the ghost run based on provided record value.

Parameters
playerTarget player.
recordRecord value.
announceRecordDetermines when to display a chat alert about a finished test. See ANNOUNCERECORD.

◆ submitRecord()

void submitRecord ( jjPLAYER@ player,
int record,
uint8 announceRecord = ANNOUNCERECORD::NEVER )

Submits a record without ending the test session and without assigning a [win] tag to a player. Can only be used on players that are in a level state (wearing a level number tag). Unlike finishTest(), this method should be used when a player reaches a significant milestone in a test, but is still in the game and can continue raising their score. When applicable, the timer will continue running, and ghost run will continue recording.

Parameters
playerTarget player.
recordRecord value.
announceRecordDetermines when to display a chat alert about a submitted record. See ANNOUNCERECORD.

◆ getRecordByPlayer()

void getRecordByPlayer ( jjPLAYER@ player,
PlayerRecordCallback@ callback )

Retrieves a player's record.

Fetches the player's record from the server and invokes the callback once the response has been received.

Parameters
playerPlayer whose record should be retrieved.
callbackFunction invoked when the server responds.
Note
The callback is invoked asynchronously.
See also
PlayerRecordCallback

◆ getRecordByRank()

void getRecordByRank ( int rank,
RankRecordCallback@ callback )

Retrieves an indexed record.

Fetches a record based by rank number from the server and invokes the callback once the response has been received.

Parameters
rank1-indexed record number.
callbackFunction invoked when the server responds.
Note
The callback is invoked asynchronously.
See also
RankRecordCallback

◆ getRecordCount()

void getRecordCount ( RecordCountCallback@ callback)

Retrieves the total number of records.

Fetches the total number of records from the server and invokes the callback once the response has been received.

Parameters
callbackFunction invoked when the server responds.
Note
The callback is invoked asynchronously.
See also
RecordCountCallback

◆ formatRecord()

string formatRecord ( int record)

Returns a string representation of a record. Uses the format and units defined in configureCustomRanking().

Parameters
recordto be formatted

◆ practiceModeEnabled()

bool practiceModeEnabled ( )

Checks whether practice mode is enabled.

Returns
True if practice mode is enabled, false otherwise.

◆ disableQuickSuicide()

void disableQuickSuicide ( )

Prevents players from using the "quick suicide" assist tool.

Must be called by the server. Has no effect when called by a client.