| 12-10-2006, 05:06 AM | #1 |
Ok i'm trying to do a trigger where a Player selects an item and Item name is displayed to every player and then all players type in a "-cast lot" and assigns a random number between 1-999 now all players do this and the highest "Number" wins the item.now what I am having prolblems is finding out the highest number from a list of 12. if you could help me out i would really apreciate it.I know it has something to do with a loop action but i am not really that experienced in triggers. |
| 12-10-2006, 05:11 AM | #2 |
If you keep track of every integer, isn't it possible to run each integer through a "Number[a] is greater then Number[b]"? Then, whichever is larger can be run through Number[c], and so on. I don't have the world editor open right now, so that's all I can really say. If you can do it that way, the numbers will filter correctly. |
| 12-10-2006, 06:13 AM | #3 |
Heres some code that should give you the jist of how to do it: JASS:local integer highest = 0 local integer index = 1 loop exitwhen index > 12 if Number[index] > highest then set highest = Number[index] endif set index = index + 1 endloop In different terms, it goes through each player's integer (which I will assume you have defined as Number[ player # ] and compares it to the "highest" number (which at the beginning is 0, so unless the integer is negative the first player compared will take over the position of highest). Say you have a current highest (say player 1's number was 3) of 3, and Number[index] comes up as a 9, it will replace "highest" with 9. If the next Number[index] is lower than 9, it will not replace 9, and therefore 9 will still be the withstanding "highest". Hopefully this helps. Edit: Here, I picked my ass up and got onto my editor and turned this concept into GUI, so that it will look like this: Trigger: Untitled Trigger 001
![]() Events
![]() Conditions
Finally, by the end of this procedure, the highest Number[(Integer A)] will be in the form of variable Highest. |
| 12-10-2006, 07:47 AM | #4 |
Now, the problem comes when trying to find the player that has the greatest number. Unless that's what he wants. |
| 12-10-2006, 08:17 AM | #5 |
What do you mean by finding the player witht he highest number.like what i want is the Highest number gets the item. Oh and Btw thank you for helping me |
| 12-10-2006, 10:15 AM | #6 |
Ok the trigger works but now how would i go about giving the "Highest" the Item being fought over? |
| 12-10-2006, 10:45 AM | #7 |
just use another integer (in this case called player) and set it = the loop, so you get the number of the winning player, then you can move the item to a rect or give it to an unit. I hope you know how, or? Trigger: Set Player = (Integer A) |
| 12-10-2006, 11:36 AM | #8 |
I got it to work thanks guys |
