• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to find the highest value

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I started this thread as a "Multiboard data update" but I noticed the title isn't appropiate.

I save all my tower kills and damage dealt so far during lifetime in a Hashtable under the towers handle. I need to find which tower has the highest number of kills or damage dealt, and know who owns it. How can I do that?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Like this? I know it's a mix of jass and GUI, I just need to know if the general idea works and it's easy + efficient.

JASS:
Set i = 0
Set MaxDamage = 0.00

Unit - Pick Every Unit in TowerGroup and do:
   Set i = i +1 
   Set Tower[i] = (Picked Unit)

For each Integer A from 1 to (Number of Units in TowersGroup) do (Actions)
   Custom Script: Set int = GetHandleId(Towers[GetForLoopIndexA()])
   Set r = Load 1 of int in Hash
   If r > MaxDamage then
      Set MaxDamage = r
      Set MaxTower = Towers[Integer A]
      Set Owner = Player number of (Owner of MaxTower)
   endif
 
Status
Not open for further replies.
Top