Hi all,
Someone emailed me asking if I would be so kind to show him how to set up a voting system for his map, so I figured I'd help him out and let everyone else know I'm alive at the same time.
In order to do this, you'll need several variables for the dialog and the counting. I'm only doing a two choice box, but any number of additional variables can be added. The variables I'll be using will be:
- MyDialog- A "Dialog"-type variable.
- Choice1- A "Dialog Button"-type variable.
- Choice2- Another "Dialog Button"-type variable.
- Choice1Counter- An "Integer"-type variable.
- Choice2Counter- Another "Integer"-type variable.
There are three main parts to setting this up:
- Dialog box and button setup
- Voting counting
- Voting Ending & End Tally
So to start with the dialog box... **
VERY IMPORTANT** Your dialog setup trigger cannot have "Map Initialization" for its event, because Warcraft 3 will not run your dialog like that. It's better to set it up with a delay, anywhere from .01 seconds to 2-3 (as shown):
Next, the buttons must be first created and then made to equal a variable value, like so:
Now that your dialog is set up, you want to keep track when a person clicks an option, and hide the dialog after they vote so they can't vote again. This example will be for the first choice only, but all that needs done is to change 'Choice1' and 'Choice1Counter' to 'Choice2' and 'Choice2Counter':
This step is open for you to interpret and change to your personal situation, but there should be a point where voting ends. It would be simple to create a timer on the screen that shows when voting ends, but I'm sticking to the basics. I'm ending this one after 30 seconds:
Finally, the good part, the results of your vote. After you tell the game to close everyone's voting dialog, you give the game an 'If/Then/Else' action for each voting option, where if it has more votes then the others, something happens. For mine, I made it play one sound for the first choice and a different sound for the second.
(**I realized that I could have combined this trigger with the last one and it would have been less clutterwork, but I already had the pic taken and uploaded, so use your imaginations
**):
Ok, there you have it. I'm not saying this will fit every situation, or that this is a great example of how to do it, but it's the best I'm willing to do, considering I've never put one in any maps I've made. I hope this will help any mapmakers along their path should they need this.
As always, Peace Out!