openplanet Download Openplanet Login with ManiaPlanet

The app object

The center brain of ManiaPlanet is the CGameCtnApp object and its descendants. From here, you can access most of the game's objects. You can see this object and what it currently contains in the Nod explorer. The base object is (as of writing this) always CTrackMania, regardless of game. However, in case Nadeo ever changes this in the future, Openplanet uses the base class CGameCtnApp. To get this object in your plugin, you use the CGameCtnApp@ GetApp() function.

void Main()
{
  CGameCtnApp@ app = GetApp();
}

If you need access to a child class (eg. CTrackMania in this case), you have to explicitly cast it, like this:

void Main()
{
  CTrackMania@ app = cast<CTrackMania>(GetApp());
}

This works for every Nod object. If the type being cast to is not actually of that type, it will return null.

Continue to the next page: Printing the amount of planets