Home   Help Search Login Register  

Author Topic: Showing Highest Scoring Player  (Read 1200 times)

0 Members and 2 Guests are viewing this topic.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Showing Highest Scoring Player
« on: 20 Jan 2003, 17:36:26 »
I want to show the highest scoring player at the end of the game, when i show the final score


Please help
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Tactician

  • Guest
Re:Showing Highest Scoring Player
« Reply #1 on: 21 Jan 2003, 08:31:01 »
For a quick example:

playerArray exec "HighScore.sqs"

Code: [Select]
;; begin HighScore.sqs
_arrayOfPlayers = _this
_i = 0
; two lines below initialize highest score/player
_highestScore = score (_arrayOfPlayers select 0)
_highestPlayer = (_arrayOfPlayers select 0)
; this loops until all players in array have been checked
while {_i < count _arrayOfPlayers} do {if (score (_arrayOfPlayers select _i) > _highest) then {_highestScore = score (_arrayOfPlayers select _i); {_highestPlayer = (_arrayOfPlayers select _i)}; _i = _i + 1}
;; end HighScore.sqs

From the while statement to the end of the script is one long crazy line.  _highestPlayer ends up being the guy with the highest score.  This example won't help you much if two people are tied for first, but with a little more work there is a way around that.

This would probably make a better function, since then you'd be able to return the result (and you'd be able to write the loop on multiple lines).  Something for you to work on.

And sorry if the above example doesn't work as planned.  Practice debugging someone else's quick scripts, it'll be fun ;)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Showing Highest Scoring Player
« Reply #2 on: 21 Jan 2003, 09:13:06 »
Thanks a lot, if i go bald sorting this out, iill send the phsychiatrists bill to you  


Thx m8 ;D
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123