• 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.

whats wrong with this code?

Status
Not open for further replies.
Level 5
Joined
Jan 12, 2010
Messages
132
So ,I have this code that is supossed to calculate the players top based on players overall score.It work fine if players score arent equal.If are equal one or mere is doomed.All top place 1st 2nd etc are ocuped by one player.How should it look to work fine?

  • For each (Integer A) from 2 to 5, do (Actions)
    • Loop - Actions
      • Set Score_total[(Integer A)] = ((Player((Integer A))) Total Overall Score)
  • Player Group - Pick every player in PPL_gr and do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set Score = Score_total[((Integer A) + 1)]
          • Set B = ((Integer A) + 1)
          • For each (Integer B) from 1 to 4, do (Actions)
            • Loop - Actions
              • Set C = (C + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Score Greater than or equal to Score_total[((Integer B) + 1)]
                • Then - Actions
                  • Set Rank[B] = (Rank[B] + 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • C Equal to 4
                    • Then - Actions
                      • If (Rank[B] Equal to 4) then do (Set Top[1] = (Player(B))) else do (Do nothing)
                      • If (Rank[B] Equal to 3) then do (Set Top[2] = (Player(B))) else do (Do nothing)
                      • If (Rank[B] Equal to 2) then do (Set Top[3] = (Player(B))) else do (Do nothing)
                      • If (Rank[B] Equal to 1) then do (Set Top[4] = (Player(B))) else do (Do nothing)
                    • Else - Actions
                • Else - Actions
Score_total variable integer that represent players overall score .
Players 2-5 are players used on my map.
Top is supposed to be a ranking.
So if all players score are different it`s work very fine but if players score are same its messed with one players ocuping all place (ex: 1st 2nd 3th etc).
So if u have any ideea (a good one ) replay pls..else..
 
Last edited:
Level 9
Joined
Jul 10, 2011
Messages
562
1. what you wanna do with this trigger Oo

2. you dont have Integer B!!!

3. your trigger doesnt make any sense at all...you loop through the score of the players 2 to 5...then you loop though every player in a certain group and in this loop you loop from 1 to 4 again doing things i dont even understand Oo and beside i dont understand them in the triggering sense they are absurd...
a) C = Integer A
b) Score = Score_total(Integer A + 1)
c) Rank is nothing as far as i can see
d) why you set B Oo Its just (Integer A + 1)
e) already said in 2. but you dont even have Integer B but you set variables to it
f) when you already set B why you dont use it for the line over it??? Oo



give us an understandable question and think of the trigger before you do it....and beside that....read the trigger if it doesnt work...and if you dont see a mistake while reading use debug messages.


greetz and hopes that you got what i tried to say

happy
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Here is the pesudo code for a bubble sort.
Code:
procedure bubbleSort( A : list of sortable items )
  repeat
    swapped = false
    for i = 1 to length(A) - 1 inclusive do:
      if A[i-1] > A[i] then
        swap( A[i-1], A[i] )
        swapped = true
      end if
    end for
  until not swapped
end procedure
 
Status
Not open for further replies.
Top