ID:170796
 
Hey, I'm having a problem. I'm trying to make a voting system, and in this voting system, it counts the votes. It counts the votes, by looping through a list of players in the list, and checks their Voted var first to see if they voted, then if true, it checks their VotedFor var to see if it voted for the choice, if true, it SHOULD add one vote to that choice's votes. But, that is where I am stuck, I can't figure out how to establish a var for each choice called "Votes." So far, I've tried..

var/Choice/Votes = 0


Choice/var/Votes = 0


and

var/VotingSystem/Choice/Votes = 0 //lol.


None of them worked, what am I doing wrong?

[EDIT]

Now, instead of looping through the choices AND the players, it just loops through the players, and I made a proc called AddToVote, and it just calls AddToVote(M.VotedFor) once it checks the player's Voted var.
var/choice1name //name of choice 1 in votes we define what it actually is later
var/choice2name //name of choice 2 in votes we define what it actually is later
var/choice1num = 0 //number of votes choice 1 recieves
var/choice2num = 0 //number of votes choice 2 recieves

mob
verb
AskForVotes()
choice1name = input("Choice1") as text //name what choice 1 is
choice2name = input("Choice2") as text //name what choice 2 is
for(var/mob/Player/M in world) //change this if all clienty player's have a dif type
switch(input(M,"What would you like to vote for?") in list(choice1name,choice2name) //ask everyone what they want to vote for
if(choice1name) //if they went for choice 1
choice1num ++ //add a vote to choice 1
else if(choice2name)
choice2num ++ //otherwise add a vote to choice 2

mob
Stat() //just for your own testing purposes
statpanel("Votes")
stat("[choice1name] has [choice1num] votes"
stat("[choice2name] has [choice2num] votes"


I know this isn't excatly what you asked for, but it should give an idea.

Btw it's totally untested.
In response to DeathAwaitsU
Well, It was a good try. The problem with going any way like that is the number of choices WILL change, and is unpredictable, and I don't want to limit it THAT much.

[EDIT]

Question: What if I just did this?

var/Votes[] = 0
Votes["[Choice.name]"] += 1


? Would that work?
In response to Lenox
What do you mean the number of choices will change? There'll only be two choices with my code.
In response to DeathAwaitsU
DeathAwaitsU wrote:
What do you mean the number of choices will change? There'll only be two choices with my code.

I already have everything but the counting of choices, I don't want to limit it to only two choices to vote on.