Git Product home page Git Product logo

elrubioloco / howmanycontenders Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 47 KB

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.

Home Page: https://openplanet.dev/plugin/howmanycontenders

License: GNU General Public License v3.0

AngelScript 98.91% ActionScript 1.09%
angelscript maniaplanet openplanet plugin trackmania trackmania2020

howmanycontenders's Introduction

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.

Changelog

Opened plugin to starter access users. Added an icon to the plugin to make it more aesthetic.

Fixed a bug that made the plugin unusable for users belonging to zones that has less than 5 divisions.

Initial version, allowing to see the total count of players that have a time on the map currently played, separated by the zone you belong to.

NB : there is an issue in Nadeo API that makes us unable to get the real total count when we arrive on a map that has already been played by the user (We consider that the map has been played from the point where the user has a time on it).

Credits

Many thanks to @Banalian (Lilian Pouvreau) for developping his plugin ExtraLeaderboardPositions and letting people look at the source code. It has been very helpful for me and I would never be able to develop HowManyContenders without it.

License

2023 Martin CORNU-MANSUY [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

howmanycontenders's People

Contributors

elrubioloco avatar

Stargazers

 avatar

Watchers

 avatar

howmanycontenders's Issues

Plugin not available for Starter Access

My settings in openplanet are set, so it should always be showing, but it never shows up anywhere on my screen. There is no error message or anything, just doesn't appear. Would appreciate potential solutions, thank you!

Use another API call to get number of contenders

Have to consider using request down below to get the counts of contenders.

POST https://live-services.trackmania.nadeo.live/api/token/leaderboard/group/map?scores[{mapUid}]={score} API call.

See documentation HERE.

It seems to return zones :

[
    {
        "groupUid": "Personal_Best",
        "mapUid": "gjt2DWATrQ_NdrbrXG0G9oDpTfh",
        "score": 15800,
        "zones": [
            {
                "zoneId": "301e1b69-7e13-11e8-8060-e284abfd2bc4",
                "zoneName": "World",
                "ranking": {
                    "position": 294,
                    "length": 0
                }
            }
        ]
    },
    {
        "groupUid": "Personal_Best",
        "mapUid": "XiGZvMOqIgT3_g0TdeFa0lxMp46",
        "score": 17500,
        "zones": [
            {
                "zoneId": "301e1b69-7e13-11e8-8060-e284abfd2bc4",
                "zoneName": "World",
                "ranking": {
                    "position": 42,
                    "length": 0
                }
            }
        ]
    }
]

Error on launch

This error appears for an user whenever he or her install the plugin
image
image

Too many refreshes

We don't need as much refreshes. By now we have like 2 refreshes every 3 sec. We only need one for 20s or one by restart. or even one by new map played.

Weird error using built-in array methods

In my split string method, the built-in array methods calls generate errors :

  • ERR: No matching symbol 'insertLast'
  • ERR: No matching symbol 'findFirst'

Here is my function :

array<string> splitString(const string& in str, const string& in delimiter) {
    array<string> result;
    
    int startPos = 0;
    int endPos = str.findFirst(delimiter);
    
    while (endPos != -1)
    {
        result.insertLast(str.substr(startPos, endPos - startPos));
        startPos = endPos + delimiter.Length;
        endPos = str.find(delimiter, startPos);
    }
    
    result.insertLast(str.substr(startPos));
    
    return result;
}

Here the array is correctly initialized and the used methods are referenced here in AngelScript documentation...

CGameScoreAndLeaderBoardManagerScript::MapLeaderBoard_GetPlayerCount returns 0

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.

API Call returns my position by zone instead of the position i would get with the worst time possible

See doc here

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;
            }

            string requestBody = '{"maps": [{"mapUid": "'+mapid+'","groupUid": "Personal_Best"}]}';

            Json::Value data = PostRequest(NadeoServices::BaseURL() + "/api/token/leaderboard/group/map?scores["+mapid+"]="+maxint, requestBody);
            if (data.GetType() != Json::Type::Null) {
                Json::Value zones = data[0]["zones"];
                 
                if (zones.GetType() == Json::Type::Array){    
                    // Never goes there.
                    print(zones.Length);
                    for (uint i=0; i<zones.Length; i++) {
                        zoneContenders[i] = zones[i]["ranking"]["position"];
                    }
                }
            }
        }
    }

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.