ID:174443
 
How do I make a vote system like vote a certain person since I'm trying to make a gm voting system so I can see whos a good gm and whos a bad gm it be very helpful if you can tell me how to do that.
mob
var
good=0
bad=0
total=0
verb
View(mob/M)
var/percentg=round(M.good/M.total)*100
var/percentb=round(M.bad/M.total)*100
usr<<"[M]'s good percentage is [percentg], while \his bad percentage is [percentb]. This was based off of a total of [M.total] total votes."
Vote(mob/M)
switch(input("How would you rate [M]?","[M]")in list("Good","Bad"))
if("Good")
M.good++
M.total++
if("Bad")
M.bad++
M.total++
In response to Swimmer4LifeH2O
Uhhhh, why do you need total if it should always be the sum of good and bad? And when do you need a good and bad percentage calculated when it's obvious that they should add up to 100%, and thus you can get the other by subtracting the first one from 100. So much redundancy...
In response to Swimmer4LifeH2O
Thanks but when I compiled I got errors is that right?
In general I think you're going to find a voting system won't tell you what you want to know, here. Democracy among trolls doesn't work; they'll tend to say just about anybody is bad, except one of their own number, and they'll find ways to abuse the system.

But if you'd like to see that for yourself, then I recommend this at least: Keep track of each person's vote, so they can't vote twice. (At most, allow them to change or rescind their vote.) An associative list will do well enough: Just associate by key.
if(voter.key)
// vote is >0 (good), 0 (no vote), or <0 (bad)
myvotes[voter.key] = vote
Then to tally votes:
var/total = 0
var/good = 0
for(var/key in myvotes)
if(!myvotes[key]) // a non-vote
myvotes -= key
continue
++total
if(myvotes[key] > 0) ++good // a positive vote
if(total)
src << "You have a [round(good * 100 / total, 1)]% rating (out of [total] vote\s)"

Lummox JR