HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make a vote system?

02-17-2004, 05:16 PM#1
Soultaker
Hi how do you make a vote system and which one if best? Dialog, Text or ?
02-17-2004, 06:37 PM#2
dexllgamer
Text = easier = not as cool or slick
Dialog = hard = very cool and slick

so i assume your cool

Make 6 variables, 1 dialog window, 2 dialog buttons (1 yes and 1 no), and 3 integers (1 voted yes, 1 voted no, and 1 number of votes)

Event:
Elapsed time 1 second
Conditon:
none
Action:
Create dialog window labled with your question (i.e. do you want to play?)
set varible set (dialog window varible) = last created dialog window
add button labled yes to last created dialog window
set varible (yes button = last created button)
add button labled no to last created dialog window
set varrible (no button varrible = last created button)
Pick all players and show (dialog window verrible here)

Next trigger (someone votes yes)
Event:
Event respeonse: Dialog button (button verrible yes) is pressed
Condition:
none
Event:
Set varrible (voted yes) = (voted yes) + 1
Set varrible (number of votes) = (number of votes) + 1
Run trigger (the decision)

Next Trigger (someone votes no)
Event:
Event respeonse: Dialog button (button verrible no) is pressed
Condition:
none
Event:
Set varrible (voted no) = voted no + 1
Set varrible (number of votes) = (number of votes) + 1
Run trigger (the decision)

Next Trigger (the decision)
Event:
none
Condition:
integer comparision varible number votes = number of players matching condition (is playing) {<-slot status comparion}
Event:
if/then/else If yes votes varrible is greater than or equal to no votes varible do (your action here) other wise do nothing.
if/then/else If no votes varible is greater than no votes varible do (your action here) other wise do nothing.

No time to check my work. I was working all from memory. But i think you get the jist of it. What i said may not be perfect, but this IS how you do it.

GOOD LUCK HAVE FUN!!!

Dam i should get some sort of award for that. That was a lot of typing.

:D :ggani: 0_o emote_sweat :foot: :mtk: :lch: :guns: :knife: :dance: :abomHUH?: :hm: :whoa2: :no: :ohh: :D ://// :foot: :bgrun: emote_confused :mtk: :guns: :guns: :arch: :infth: :lch:
02-17-2004, 11:08 PM#3
Blesser
Variables:
-Easy = Dialog Button
-Normal = Dialog Button
-Hard = Dialog Button
-NumberVotes = Integer
-PlayerNumber = Player Group
-Vote = Dialog
-VoteEasy = Integer
-VoteNormal = Integer
-VoteHard = Integer

Create Dialog
Events:
Time - Elapsed game time is 1.00 seconds

Actions
Set PlayerNumber = (All players matching (((Matching player) slot status) Equal to Is playing))
Player Group - Pick every player in (All players) and do (Dialog - Create a dialog button for Vote labelled Hard)
Set Hard = (Last created dialog Button)
Player Group - Pick every player in (All players) and do (Dialog - Create a dialog button for Vote labelled Normal)
Set Normal = (Last created dialog Button)
Player Group - Pick every player in (All players) and do (Dialog - Create a dialog button for Vote labelled Easy)
Set Easy = (Last created dialog Button)
Dialog - Change the title of Vote to Difficulty:
Player Group - Pick every player in (All players) and do (Dialog - Show Vote for (Picked player))

Easy
Events
Dialog - A dialog button is clicked for Vote
Conditions
(Clicked dialog button) Equal to Easy
Actions
Set VoteEasy = (VoteEasy + 1)
Set NumberVotes = (NumberVotes + 1)
Trigger - Run Decision <gen> (checking conditions)

Normal
Events
Dialog - A dialog button is clicked for Vote
Conditions
(Clicked dialog button) Equal to Normal
Actions
Set VoteNormal = (VoteNormal + 1)
Set NumberVotes = (NumberVotes + 1)
Trigger - Run Decision <gen> (checking conditions)

Hard
Events
Dialog - A dialog button is clicked for Vote
Conditions
(Clicked dialog button) Equal to Hard
Actions
Set VoteHard = (VoteHard + 1)
Set NumberVotes = (NumberVotes + 1)
Trigger - Run Decision <gen> (checking conditions)

Decision
Conditions
NumberVotes Equal to (Number of players in PlayerNumber)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VoteEasy Greater than VoteHard
VoteEasy Greater than VoteNormal
Then - Actions
What you wan't to happen
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VoteHard Greater than VoteEasy
VoteHard Greater than VoteNormal
Then - Actions
What you wan't to happen
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
VoteNormal Greater than VoteHard
VoteNormal Greater than VoteEasy
Then - Actions
What you wan't to happen
Else - Actions
Do nothing
02-17-2004, 11:24 PM#4
Satz
I would use a Dialog Button Array, as I always want to leave myself room to add more stuff later on.

The dialog button array would allow you to start off with say : Easy Normal and Hard, but then later on expand that to Very Easy, Easy, Normal, Hard, Very Hard.

And it would cut down on your variables.

So Instead of making the dialog button variables, just make a dialog button array, and where you would normally set the last dialog button to a name set it to a number eg - DialogArray(1).

Its the same as the Integers, I would make an array where they corrispond to the dialog buttons.

Give me like a couple of minutes and I will reply with the triggers.


Edit>> Okay here we go. (In advance I pwn j00) :D


Variables. (5)

Quote:
szv_buttontext (string array)
szv_dialog (dialog)
szv_dialogbuttons (dialog button array)
szv_integer (integer)
szv_votescast (integer array)



Triggers (3)

The following trigger is the one you edit, just copy and paste start add button to end add button and everything will take care of itself. I have added three there but you can make it two, or eight, or whatever you fancy.

Quote:
SZV Set Variables

Events
Time - Elapsed game time is 1.00 seconds

Conditions

Actions
-------- The title of your dialog. --------
Set szv_buttontext[0] = What difficulty setting?
-------- How long should you wait for people to vote? --------
Set szv_votescast[0] = 10
-------- ADD BUTTONS UNDER THIS COMMENT --------
-------- Start Add Button --------
Set szv_integer = (szv_integer + 1)
Set szv_buttontext[szv_integer] = Easy
-------- End Add Button --------
-------- Start Add Button --------
Set szv_integer = (szv_integer + 1)
Set szv_buttontext[szv_integer] = Normal
-------- End Add Button --------
-------- Start Add Button --------
Set szv_integer = (szv_integer + 1)
Set szv_buttontext[szv_integer] = Hard
-------- End Add Button --------
-------- ADD BUTTONS ABOVE THIS COMMENT --------
Trigger - Run SZV Engine <gen> (ignoring conditions)



This just says if a dialog button is clicked, update the array.

Quote:
SZV Dialog Clicked

Events
Dialog - A dialog button is clicked for szv_dialog

Conditions

Actions
-------- You do not need to edit anything in this Trigger --------
-------- --------
For each (Integer A) from 1 to szv_integer, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to szv_dialogbuttons[(Integer A)]
Then - Actions
Set szv_votescast[(Integer A)] = (szv_votescast[(Integer A)] + 1)
Else - Actions
Do nothing



This is the engine of the script, all the caculations and stuff is done here. I have added a quest that states who made the script, if your going to use it just give me credit.

If there is a tie in the vote, then it will choose the lower button of the two, normally the hardest.

If there is no vote then it will pick a random setting.

To tell it what to do once it has picked a setting, just make a new trigger that is run after this one is finished, and do If (szv_votescast(0) is equal to 1 then do : If it is two then do : etc etc etc....

Quote:
SZV Engine

Events

Conditions

Actions
-------- You do not need to edit anything in this Trigger --------
-------- --------
Quest - Create a Optional quest titled Voting System with the description Hi I am using Satz's Voting System.

This uber 1337 voting system is really cool, and extremely easy to use. I mean heck, I saved hours and reduced lag by using this script.

You can download a copy of this script from AiiXiiA.

www.aiixiia.com , using icon path ReplaceableTextures\CommandButtons\BTNPossession.blp
Game - Display to (All players) for (Real(szv_votescast[0])) seconds the text: ((You have + (String(szv_votescast[0]))) + seconds to make your vote.)
Dialog - Change the title of szv_dialog to szv_buttontext[0]
For each (Integer A) from 1 to szv_integer, do (Actions)
Loop - Actions
Dialog - Create a dialog button for szv_dialog labelled szv_buttontext[(Integer A)]
Set szv_dialogbuttons[(Integer A)] = (Last created dialog Button)
Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
Loop - Actions
Dialog - Show szv_dialog for (Picked player)
Wait (Real(szv_votescast[0])) seconds
Set szv_votescast[0] = 0
Game - Display to (All players) the text: Voting time is up!
Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
Loop - Actions
Dialog - Hide szv_dialog for (Picked player)
For each (Integer A) from 1 to szv_integer, do (Actions)
Loop - Actions
For each (Integer B) from 1 to szv_integer, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
szv_votescast[(Integer A)] Greater than szv_votescast[(Integer B)]
Then - Actions
Set szv_votescast[0] = (Integer A)
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
szv_votescast[0] Equal to 0
Then - Actions
Set szv_votescast[0] = (Random integer number between 1 and szv_integer)
Else - Actions
Do nothing
Game - Display to (All players) the text: (The picked difficulty is + szv_buttontext[szv_votescast[0]])
02-18-2004, 01:30 AM#5
Krin
AhhHHhhH Overload! Man I dont ever do complicated **** like that.. I guess I shine more at unit balance and ability creation :////
02-18-2004, 01:40 AM#6
Satz
It is extremely easy, I have updated that post with how it works.

Basically all you have to do is edit the set variables trigger.

Everything else takes care of itself, the engine is not really that complicated, all it does basically is:

Shows the dialog.
Waits a number of seconds.
Hides the dialog for players who did not vote.
Checks for the largest score.
Then checks if there is no score then to pick a random one.
Then decides the winner.

Actually Krin if you have MSN add me [email protected] I might have something you will be intrested in.