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

Vote System

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
Break the problem down into separate elements...
Firstly, you need to decide how the voting should work. It looks to me like you want it distributed so if 6 people vote easy and 6 hard it ends at medium.

This requires a global fixed variable for the outcome of the vote (to represent an average). It also requires a global integer for the number of votes cast.

Next you will need a nice looking voting dialog. Create a frame and store it to a variable. Next create 3 buttons in it and store it to a variable. Format them however appropiate with colours, funky borders or strange positioning.

Now to prevent a user using lag to cast multiple votes, use a boolean array (size large enough so that all players can be stored, rememebr arrays start from index 0 and playable players from 1).

Create a trigger to run when each of the buttons is pressed (thats an event). Check if the player has already voted (triggering player gets player who preassed button, use the boolean array created earlier). In the actions, use multiple selection to find which button was pressed and add to the outcome based on difficulty (0 for easy, 1 for medium, 2 for hard). After that, for all cases (after the selection) add 1 to the votes cast, hide the dialogue for the player and set the boolean array so that future votes from him are not counted (stops lag multi push problem).

Finally, make a trigger that will run after a period of time after the vote starts. If the vote is always at map start, you could run it at 30-60 seconds from start. The actions get the outcome and divide it by the number of votes to get a new fixed value. That value is then subject to multiple selection (multiple if statments) to check if it is in certain value ranges. If it is between 0 and 0.5, its easy, 0.5 and 1.5 its medium and 1.5 and 2.0 its hard. Ofcourse you run the appropiate actions in those statments to set the game to reflect the outcome. You finally end off by hiding the dialogue for all players and destroying it (and all buttons it contains) as well as the trigger for responding to the button pushes.

It may not be the best solution but it should work for you if you follow the above. Really that is all there is to such a system.
 
Status
Not open for further replies.
Top