[Trigger] Vote with a few options

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
So i have a list of things to choose from.
for example the amount of points needed to win.
i have a dialog come up with 20/30/40/50 and 100 points options to vote on.

just was wondering if theres a better/more efficient way to do this. wasnt really thinking too much about it when i threw this together.

I dont bother showing the dialog as it doesnt really matter
  • CTF Button Points
    • Events
      • Dialog - A dialog button is clicked for Dialog_CTF
    • Conditions
    • Actions
      • Dialog - Hide Dialog_CTF for (Triggering player)
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Dialog_CTFPoints_Buttons[(Integer A)]
            • Then - Actions
              • Game - Display to (All players) for 8.00 seconds the text: (Voted + Dialog_CTF_Strings[(Integer A)])
              • Set Vote_Count[(Integer A)] = (Vote_Count[(Integer A)] + 1)
            • Else - Actions
The above adds up for each vote it takes.

this below orders from least to greatest to make it easy to find the largest number.
Problem is i have no easy way now to assign the value it has.
like for the var[2] its 30 points and var[5] is 100
but in this process the var is the votes it gets so this way wont work.
I need to keep the original vote in the same var[int] so i know what array value it has so i know the points to assign it after i found out the highest vote.
its kind of late now not thinking the best but i would like to finish this lol
  • Take Vote Tally 5
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Vote_Count[(Integer A)] Less than Vote_Count[(Integer B)]
                  • (Integer A) Greater than (Integer B)
                • Then - Actions
                  • Set Temp_Integer = Vote_Count[(Integer B)]
                  • Set Vote_Count[(Integer B)] = Vote_Count[(Integer A)]
                  • Set Vote_Count[(Integer A)] = Temp_Integer
                • Else - Actions
      • Set CTF_Points_Cap = Vote_Count[5]
      • Game - Display to (All players) for 9.00 seconds the text: (|c00FF0000Majority Voted|r |c00FFCC00 + ((String(CTF_Points_Cap)) + |r |c00FF0000points for the Win!|r))
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set Vote_Count[(Integer A)] = 0
ill keep working on this and check back on this from time to time.
 
Last edited:
Level 13
Joined
Mar 24, 2010
Messages
950
i would have done that if i didnt have to display a different message everytime. so it wouldnt work for me using intA for the first trigger.


Anyone wanna help me with the 2nd part? thats all i really need lol.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You can store the strings (which display when voted) in a variable and use the loop either way.
Edit: lol, I should really stop being afk after opening a thread...

Mehh, I would've taken the avarage (e.g.: 1 vote for 50 kills, 1 vote for 100 kills -> set to 75 kills).
That way everyone is happy + it's easier.

If you want to do it your way, you can store var[6] to var[10] as the points needed to win (var[6] = 20, var[7] = 30 etc).
That way you use the array a little bit more without using another variable, thus being a tad more efficient.
 
Level 13
Joined
Mar 24, 2010
Messages
950
lol nice dont know why i didnt even think of that ^^ was too tired

ill work on that now, maybe show an example in case i dont get it right lol cant think today

Edit:
Only easy way i can think to do it is make another int array var and have it also store the vote count in the "CTF Button Points" trigger, and then after i figure out the highest vote and store it in Vote_Count[5] in "Take Vote Tally 5" trigger,
I would then just do a quick loop compare with Vote_Count[5] and the new int var array that didnt have the real votes overwritten i would see what vote matched the integer in Vote_Count[5] and then i would know what the array index would be for knowing the right number of points to make it.
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
Maybe something like this:

Inside your "Map Initialization"-trigger:

  • Actions
    • Set Vote_String[1] = String 1
    • Set Vote_String[2] = String 2
    • Set Vote_String[3] = String 3
    • Set Vote_String[4] = String 4
    • Set Vote_String[5] = String 5
    • Set Vote_Count[6] = 20
    • Set Vote_Count[7] = 30
    • Set Vote_Count[8] = 40
    • Set Vote_Count[9] = 50
    • Set Vote_Count[10] = 100

Your main dialog thingy:

THIS ALSO PARSES THE RESULTS! NO OTHER TRIGGER NEEDED!
  • CTF Button Points
    • Events
      • Dialog - A dialog button is clicked for Dialog_CTF
    • Conditions
    • Actions
      • For each (Integer LoopInt1) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Dialog_CTFPoints_Button[LoopInt1]
            • Then - Actions
              • Game - Display to (All players) the text: (((Name of (Triggering player)) + voted for ) + Vote_String[LoopInt1])
              • Set Vote_Count[LoopInt1] = (Vote_Count[LoopInt1] + 1)
              • Set Vote_Count[11] = (Vote_Count[11] + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Vote_Count[11] Equal to (Number of players in (All players controlled by a User player))
        • Then - Actions
          • -------- Parsing results --------
          • Set Vote_Count[12] = 0
          • Set Vote_Count[13] = 0
          • For each (Integer LoopInt1) from 1 to 5, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Vote_Count[LoopInt1] Greater than Vote_Count[13]
                • Then - Actions
                  • Set Vote_Count[13] = Vote_Count[LoopInt1]
                  • Set Vote_Count[12] = LoopInt1
                • Else - Actions
          • -------- Showing results --------
          • Game - Display to (All players) the text: (Points Required: + (String(Vote_Count[(Vote_Count[12] + 5)])))
        • Else - Actions
Index:
  • Vote_Count[1...5]: The amount of votes a certain option has.
  • Vote_Count[6...10]: The amount of points for every option.
  • Vote_Count[11]: The amount of players who voted.
  • Vote_Count[12]: The highest ranked Vote_Count (integer between 1 and 5).
  • Vote_Count[13]: The amount of votes the currently highest ranked Vote_Count has.

If you combine a few, the points required to win is:
Vote_Count[Vote_Count[12] + 5].
(Vote_Count[12] == integer between 1-5, +5 because the stored variables were in 6-10).

I know, a lot of different things with the same variable, but honestly: I like it this way =D
(I hope everything works, I didn't test anything, just wrote down what I thought xD But well, I can still think a little bit so it should be about correct).
 
Last edited:
Level 13
Joined
Mar 24, 2010
Messages
950
nice, thanks ill check this out.

probably wont use the index 11 for storing users and doing a check though becuz theres no real need. i only show the dialog to ppl that are still playing also if someone left the game it would stop the trigger at
  • if Vote_Count[11] Equal to (Number of players in (All players controlled by a User player))
because theres no "and" check for if they are still playing also.
and im mostly just looking for the highest vote. i like the bottom check though ill use that. thanks :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Well, the Vote_Count[11] is mainly used to check when all players voted, no matter who you show the dialog to.
Because of Vote_Count[11] you can combine the vote parsing with the voting (combining 2 triggers).

And it was just an example for you to use, so it wasn't perfect either way :)
I hope you put it to good use! (And probably tweak is where needed).
 
Status
Not open for further replies.
Top