OgarProject / Ogar

An open source Agar.io server implementation, written with Node.js.
Other
719 stars 820 forks source link

Scoreboard not working #655

Open SPMNJ opened 8 years ago

SPMNJ commented 8 years ago

[Game] Loaded stats server on port 88 [Game] Listening on port 443 [Game] Current game mode is Rainbow FFA TypeError: Object doesn't support property or method 'leaderboardAddSort' at FFA.prototype.updateLB (C:\Users\Sean\Documents\Ogar-master\src\gamemodes\FFA.js:78:13) at GameServer.prototype.mainLoop (C:\Users\Sean\Documents\Ogar-master\src\GameServer.js:390:17) at tryOnTimeout (timers.js:224:5) at listOnTimeout (timers.js:198:5) TypeError: Object doesn't support property or method 'leaderboardAddSort' at FFA.prototype.updateLB (C:\Users\Sean\Documents\Ogar-master\src\gamemodes\FFA.js:78:13) at GameServer.prototype.mainLoop (C:\Users\Sean\Documents\Ogar-master\src\GameServer.js:390:17) at tryOnTimeout (timers.js:224:5) at listOnTimeout (timers.js:198:5) at listOnTimeoutNT (timers.js:242:3) at _combinedTickCallback (internal/process/next_tick.js:71:11) at _tickCallback (internal/process/next_tick.js:98:9) at tryOnImmediate (timers.js:534:5) at processImmediate (timers.js:514:5)

ZfsrGhS953 commented 8 years ago

Gamemodes that are tested and supported by contributors are only FFA(ID 0), Teams(ID 1), and Experimental(ID 2)

BaumanDev commented 8 years ago

That would not be the problem. If he picks a gamemode not in the module object, it automatically becomes FFA.

ZfsrGhS953 commented 8 years ago

@NatsuTheGreat Gamemodes that are tested and supported by contributors are only FFA(ID 0), Teams(ID 1), and Experimental(ID 2)

BaumanDev commented 8 years ago

MKay

Luka967 commented 8 years ago

Rainbow doesn't have any compatibility issues for now. Replace the updateLB function at FFA with this:

FFA.prototype.updateLB = function(gameServer) {
    var leaderboard = [];

    // First off remove disconenected or spectating players
    var players = [];
    gameServer.clients.forEach(function(player) {
        if (!player) return;
        if (player.playerTracker.cells.length <= 0) return;
        if (player.playerTracker.disconnect > 0) return;
        players.push(player.playerTracker);
    });

    players.sort(function(a, b) {
        try {
            return b.getScore(true) - a.getScore(true);
        } catch (e) {
            return 0;
        }
    });

    leaderboard = players.slice(0, gameServer.config.serverMaxLB);

    this.rankOne = leaderboard[0];
    gameServer.leaderboard = leaderboard;
};