ElRubioLoco / HowManyContenders

A Trackmania Next plugin, allowing to see the total number of players who played a map.So you can more precisely see where you are in terms of performance.
https://openplanet.dev/plugin/howmanycontenders
GNU General Public License v3.0
1 stars 0 forks source link

CGameScoreAndLeaderBoardManagerScript::MapLeaderBoard_GetPlayerCount returns 0 #5

Closed ElRubioLoco closed 1 year ago

ElRubioLoco commented 1 year ago

To get the number of contenders, I use the CGameScoreAndLeaderBoardManagerScript::MapLeaderBoard_GetPlayerCount. As said in the OpenPlanet documentation, give as arguments the mapuid, a empty context and the zone of the player.

void updateContendersCount() {
        auto app = cast<CTrackMania>(GetApp());
        auto network = cast<CTrackManiaNetwork>(app.Network);

        if (network.ClientManiaAppPlayground !is null && network.ClientManiaAppPlayground.Playground !is null && network.ClientManiaAppPlayground.Playground.Map !is null) {
            if (!mapidIsValid(mapid)) {
                mapid = network.ClientManiaAppPlayground.Playground.Map.MapInfo.MapUid;
            }

            CGameScoreAndLeaderBoardManagerScript@ manager = network.ClientManiaAppPlayground.ScoreMgr;

            for (int i = 0; i<zoneContenders.Length;i++) {
                zoneContenders[i] = manager.MapLeaderBoard_GetPlayerCount(mapid, "", wstring(zoneNames[i]));
            }
}

Note that the array zoneNames is gotten by :

void updateUserZones() {
       string zonePath = cast<CTrackManiaNetwork>(cast<CTrackMania>(GetApp()).Network).PlayerInfo.ZonePath;
       zoneNames = zonePath.Split('|');
   }

Executing this code, the array zoneContenders is filled by 0.

ElRubioLoco commented 1 year ago

This way to get contenderscount isn't effecctive, so i'm closing this issue.