08.01.2012, 22:30
hm. heres a 2-pass solution:
dont try to combine those loops please
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)
}
}