Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Get highest scoring player
08-30-2011, 17:05 (This post was last modified: 08-31-2011 07:05 by Pozzuh.)
Post: #1
Get highest scoring player
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;
}

Related links

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
[-] The following 3 users say Thank You to Pozzuh for this post:
d0h! (08-30-2011), surtek (08-30-2011), Yamato (08-31-2011)
08-30-2011, 17:55
Post: #2
RE: Get highest scoring player
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
Find all posts by this user
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to some_kid for this post:
surtek (08-30-2011)
08-30-2011, 19:04 (This post was last modified: 08-30-2011 19:06 by Lemon.)
Post: #3
RE: Get highest scoring player
Code:
highPlayer = maps\mp\gametypes\_globallogic_score::getHighestScoringPlayer();

thanks to deadcrayon for sharing this.

[Image: 3dxfuvy][Image: 3rwptre][Image: 6hmvpp3][Image: 3z42dxl][Image: guza-2.gif]
Visit this user's website Find all posts by this user
Add Thank You Quote this message in a reply
[-] The following 1 user says Thank You to Lemon for this post:
iAegle (08-30-2011)
08-31-2011, 01:27
Post: #4
RE: Get highest scoring player
(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.
Related links
Find all posts by this user
Add Thank You Quote this message in a reply
08-31-2011, 02:32
Post: #5
RE: Get highest scoring player
Why did you add a check to skip people on the "axis" team. Tongue

[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Find all posts by this user
Add Thank You Quote this message in a reply
08-31-2011, 07:04
Post: #6
RE: Get highest scoring player
(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

[Image: MaEIQ.png]
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Release] player checkpoints iAegle 10 955 04-14-2012 11:55
Last Post: CVD
  Player visible on screen. master131 4 805 11-03-2011 18:35
Last Post: Yamato

Forum Jump:


User(s) browsing this thread: 1 Guest(s)
Media Embeding by Simple Audio Video Embeder