This shows how players can vote using the library.
All of the voting information is saved in the standings.
Here is the code in the project ( copy-paste-able):
world
name = "Voting Demo - Your Favorite Melee Weapon"
hub = "ComplexRobot.VotingDemo"
hub_password =
mob
Stat()
statpanel("Poll")
stat(POLL_QUESTION, "")
stat("------------------", "")
var/list/votes = GetVotes()
var/list/percs = Percentages(votes)
for (var/X in votes)
stat(X, "[percs[X]]% ([votes[X]])")
proc
GetVotes()
var/params = world.GetScores(, POLL_SCORE_NAME)
if (isnull(params))
return list()
params = params2list(params)
var/val
for (var/X in params)
val = params2list(world.GetScores(X, POLL_SCORE_NAME))
params[X] = text2num(val[POLL_SCORE_NAME])
return params
Percentages(list/L)
var/total = 0
var/list/result = new
for (var/X in L)
total += L[X]
for (var/X in L)
result[X] = round(100 * L[X] / (total || 1), 1)
return result
|
|
Recent Medals
|
Voted
Earned by The Most Interesting Man Alive Oct 23 2012, 4:27 pm
|
|
Voted
Earned by Melkivi19 Jul 18 2012, 12:04 pm
|
|