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