Player with highest score wins
#4

hm. heres a 2-pass solution:
pawn Код:
//top of the script
new MaxPlayers;
//...
//OnGameModeInit()
MaxPlayers=GetMaxPlayers();


new BestScore=-999999,Score,HighScoredPlayers;
for(new id=0;id<MaxPlayers;id++)//estimate the highest score...
{
    Score=GetPlayerScore(id);
    if(Score>BestScore)
    {
        BestScore=Score;
    }
}
for(new id=0;id<MaxPlayers;id++)//...to "collect" the players...
{
    Score=GetPlayerScore(id);//...according to that amount
    if(Score==BestScore)//if that (highest) score matches, then...
    {
        HighScoredPlayers++;//...add 1, and...
    }
}

//now the amount of players with the highscor are known, you can use it dor dividing the reward:
new Reward=1000000;//use your scripts variable for Reward

new Part=Reward/HighScoredPlayers;//...reward all (either 1 or more) players, like in the next loop, which is basically the same

for(new id=0;id<MaxPlayers;id++)
{
    Score=GetPlayerScore(id);
    if(Score==BestScore)
    {
        GivePlayerMoney(id,Part);//replace this by your method (serversided money)
    }
}
dont try to combine those loops please
Reply


Messages In This Thread
Player with highest score wins - by MR,Mr - 08.01.2012, 10:29
Re: Player with highest score wins - by Babul - 08.01.2012, 13:56
Re: Player with highest score wins - by MR,Mr - 08.01.2012, 20:11
Re: Player with highest score wins - by Babul - 08.01.2012, 22:30

Forum Jump:


Users browsing this thread: 1 Guest(s)