ItsMods
[Release] Get highest scoring player - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: [Release] Get highest scoring player (/Thread-Release-Get-highest-scoring-player.html)



Get highest scoring player - Pozzuh - 08-30-2011

Code:
getHighestScoringPlayer() { players = level.players; winner = undefined; tie = false; for( i = 0; i < players.size; i++ ) { if ( !isDefined( players[i].score ) ) continue; if ( players[i].score < 1 ) continue; if(!isalive(players[i])) continue; if ( !isDefined( winner ) || players[i].score > winner.score ) { winner = players[i]; tie = false; } else if ( players[i].score == winner.score ) { tie = true; } wait .05; } if ( tie || !isDefined( winner ) ) { winner = getRandomPlayer(); return winner; } else return winner; }



RE: Get highest scoring player - some_kid - 08-30-2011

Code:
#include common_scripts\utility; GetHighestScoringPlayer() { players = level.players; winner = undefined; for( i = 0; i < players.size; i++ ) { if ( !isDefined( players[i].score ) ) continue; if ( players[i].score < 1 ) continue; if ( !isDefined( winner ) || players[i].score > winner.score ) winner = players[i]; else if ( players[i].score == winner.score ) if( CoinToss() ) winner = players[i]; } return winner; }

Your way if there is a tie it takes a "Random player" which that player could have 0 points while the tie was at 30,000 points.
My way selects one of the two who tied randomly


RE: Get highest scoring player - Lemon - 08-30-2011

Code:
highPlayer = maps\mp\gametypes\_globallogic_score::getHighestScoringPlayer();

thanks to deadcrayon for sharing this.


RE: Get highest scoring player - some_kid - 08-31-2011

(08-30-2011, 19:04)Lemon Wrote:
Code:
highPlayer = maps\mp\gametypes\_globallogic_score::getHighestScoringPlayer();

thanks to deadcrayon for sharing this.

Yes both Pozzuh and I know that one, what we posted is a slightly modified version of that.

In case of a tie, it returns "undefined" which will cause a crash for you I bet, and our modified versions return a player in the event of a tie, avoiding the crash.


RE: Get highest scoring player - master131 - 08-31-2011

Why did you add a check to skip people on the "axis" team. Tongue


RE: Get highest scoring player - Pozzuh - 08-31-2011

(08-31-2011, 02:32)master131 Wrote: Why did you add a check to skip people on the "axis" team. Tongue

Oh fuck, that was for my mod a while ago Smile Removed