HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Voting System

05-30-2006, 07:41 PM#1
Xios
Hi i need some help with a voting system i've got, firstly it comes up with a dialog box and asks what game you want to play, then it has to calculate up everyone's votes and choose the highest vote, that game will then be played.
i have got most of that done except the part where it tallys them all up.
This is the 3 triggers i got so far:

Dialog
Trigger:
the big choose
Collapse Events
Time - Elapsed game time is 0.10 seconds
Conditions
Collapse Actions
Dialog - Clear TheBigChoose
Dialog - Change the title of TheBigChoose to Choose the game:
Dialog - Create a dialog button for TheBigChoose labelled Hamburger Hill
Set Hamburgerhillchoose = (Last created dialog Button)
Wait 0.01 seconds
Dialog - Create a dialog button for TheBigChoose labelled Speed Ball
Set SpeedBallchoose = (Last created dialog Button)
Wait 0.01 seconds
Dialog - Create a dialog button for TheBigChoose labelled Fort
Set Fort = (Last created dialog Button)
Wait 0.01 seconds
Dialog - Create a dialog button for TheBigChoose labelled Maze
Set Mazechoose = (Last created dialog Button)
Wait 0.01 seconds
Dialog - Create a dialog button for TheBigChoose labelled POW
Set POWchoose = (Last created dialog Button)
Wait 0.01 seconds
Dialog - Create a dialog button for TheBigChoose labelled SAB
Set SabChoose = (Last created dialog Button)
Wait 0.01 seconds
Player Group - Pick every player in (All players controlled by a User player) and do (Dialog - Show TheBigChoose for (Picked player))

Convert
Trigger:
Main Dialog Clicking
Collapse Events
Dialog - A dialog button is clicked for TheBigChoose
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to Hamburgerhillchoose
Collapse Then - Actions
Set vote[1] = (vote[1] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + Hamburger Hill))
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to SpeedBallchoose
Collapse Then - Actions
Set vote[2] = (vote[2] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + Speed Ball))
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to Fort
Collapse Then - Actions
Set vote[3] = (vote[3] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + The Fort))
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to Mazechoose
Collapse Then - Actions
Set vote[4] = (vote[4] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + The Maze))
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to POWchoose
Collapse Then - Actions
Set vote[5] = (vote[5] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + Prisoner Of War))
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Clicked dialog button) Equal to SabChoose
Collapse Then - Actions
Set vote[6] = (vote[6] + 1)
Dialog - Hide TheBigChoose for (Triggering player)
Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Chose + Saboutage))
Else - Actions
Wait 15.00 seconds
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Dialog - Hide TheBigChoose for (Picked player)

Count/tally
Trigger:
Tally up vote
Events
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[1] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run HH choose Copy <gen> (checking conditions)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[2] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run sb enter Copy <gen> (checking conditions)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[3] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run fort choose <gen> (checking conditions)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[4] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run MAZE CHOOSE <gen> (checking conditions)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[5] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run POW choose <gen> (checking conditions)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
vote[6] Greater than vote[(Random integer number between 1 and 6)]
Collapse Then - Actions
Trigger - Run SAB beggining <gen> (checking conditions)
Else - Actions


is there a way i could get a tally or counter instead of this?
because i think as it is random, vote [4] could be 5 and vote [2] could be 3 but vote [1] could be 7. and it would compare vote [4] with the random number vote [2], the [4] would be higher so you play game [4], but vote [1] would still be bigger!

i am very confused
05-30-2006, 08:36 PM#2
Captain Griffen
Set TempInt = 1
For each integer 2 to 6
Loop
If: vote[TempInt] < vote[integer A]
Then: Set TempInt = integer A
Else:

This would end up with TempInt being the number of the one with the highest (in the event of a draw, the lowest drawing number would be taken).
05-30-2006, 09:10 PM#3
Xios
sorry i didnt understand that was it JASS?
i think i figured it out is this ok?
i took the long way round it
Trigger:
If - Conditions
vote[1] Greater than vote[2]
Collapse Or - Any (Conditions) are true
Collapse Conditions
vote[1] Greater than vote[3]
vote[1] Greater than vote[4]
vote[1] Greater than vote[5]
vote[1] Greater than vote[6]
05-30-2006, 10:44 PM#4
Soulprovider
I have a GUI way for you that I use in my Kick voting system and its really simple.

Use the Variables you set to in your dialogue trigger and when enough votes are cast to meet the requirements in the If/Then/Else triggers then it will do whatever you want it to do just change the Events/Conditions/Actions with whetever you want and your set.
EDIT: I forgot to tell you what else you need to do
Create two variables
Your dialogue button variable = Bootred
Then create your interger variable set at 0 = kickredvalue


What you need to do with this is set it so there is enough for one vote only so I would say 4 -5 players need to vote. unless you want it less.
If you do not create that integer variable then it will not work.
Trigger:
Collapse Events
Dialog - A dialog button is clicked for Bootsystem
Collapse Conditions
(Clicked dialog button) Equal to Bootred
Collapse Actions
Set kickredvalue = (kickredvalue + 1)
If (kickredvalue Greater than or equal to 4) then do (Game - Defeat Player 1 (Red) with the message: Your peers have ele...) else do (Do nothing)
If (kickredvalue Greater than or equal to 4) then do (Game - Display to (All players) for 30.00 seconds the text: Red has been remove...) else do (Do nothing)
If (kickredvalue Greater than or equal to 4) then do (Player Group - Pick every player in Player Group - Player 1 (Red) and do (Unit Group - Pick every unit in (Units in (Playable map area)) and do (Unit - Remove (Picked unit) from the game))) else do (Do nothing)
05-31-2006, 10:16 AM#5
Captain Griffen
Quote:
Originally Posted by Xios
sorry i didnt understand that was it JASS?

No, of course it wasn't in JASS. While it wasn't exactly as it would be in GUI, it was more than enough for you to copy (you do know that '>' means 'greater than'?)

Also, your way won't work, as it uses 'or', rather than 'and'.

Soulprovider - while not very significant in a kick trigger, your triggers leak quite a bit, and also aren't what he was looking for.