ItsMods

Full Version: Get highest scoring player
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
}
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
Code:
highPlayer = maps\mp\gametypes\_globallogic_score::getHighestScoringPlayer();

thanks to deadcrayon for sharing this.
(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.
Why did you add a check to skip people on the "axis" team. Tongue
(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