Resource icon

[Open Assets] Vote 1.3

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
vote is a flexible and configurable voting system for multiplayer servers, heavily inspired by Xonotic's built-in voting system. it features a wide range of configuration settings and a basic voting dialog with keybinds to make it easy for players to use.

srb20012.png


usage​

to cast a vote, use any of the following commands:

Code:
vote call <vote>
vcall <vote>

where <vote> is the vote you want to make. you can also view usage info and available votes on the server by running any of these commands without specifying <vote>. for example:

Code:
$vcall
Usage: vote call <command>
  Where <command> is the command to request a vote upon.
Examples: vote call map map01
          vote call exitlevel
You can call a vote for or execute these commands: exitlevel map

once a vote has been started, you can either use the f1 or f2 keys to vote yes or no (it automatically votes yes for you if you were the one starting the vote) or use the following commands:

Code:
vote yes
vote no

configuring​

the voting system should work out of the box, but you'd want to at least control on what people are and aren't allowed to vote on, right? fortunately, that can be easily done using two ways.

the first way, that is recommended to do in autoexec.cfg or adedserv.cfg, is by setting the vote_commands variable to the list of commands you want to to allow. for example, on a ringslinger server:

Code:
vote_commands "timelimit pointlimit map"

this will allow people to switch to a map and set timelimit and pointlimit on the server using the voting system.

the second method, which is useful for changing votes later, is by using the addvote and delvote commands, which allows you to add or remove a single entry in the vote_commands variable:

Code:
addvote exitlevel
delvote map

console variables​

vote has a wide range of variables that can be used to configure the voting system. here's the entire list:

  • vote_call - master switch, setting this to off will completely disable the voting system, disallowing anyone from casting a vote.
  • vote_commands - configures which commands are votable, see above.
  • vote_change - if set to off, players may not change their vote after casting their vote. note that this will also prevent the voter from aborting their own vote by voting no if vote_no_stops_vote is set to yes.
  • vote_majority_factor - percentage of voters that need to have made a vote for the vote to be valid. this is used to end the vote early if one side of the vote have majority voters, where the other option would lose even if all other voters votes for the second option. defaults to 50, set to 100 if you don't want the vote to end early if one side has majority voters.
  • vote_majority_factor_of_voted - defines the absolute minimum amount of accepted votes for a vote to pass. this can be used to "bias" towards rejecting votes if not enough people accepted the vote. for example, setting this to 66 means that 2/3 of all players must vote yes for the vote to be pass. defaults to 50, which balances accept and reject evenly.
  • vote_no_stops_vote - if on, the one that initiated the vote can immediately abort it by rejecting their own vote. note that setting this to off still allows the voter to cancel their own vote by running the command vote stop in the console.
  • vote_nospectators - if on, spectators are not allowed to vote and will be excluded from the final tally.
  • vote_stop - time, in seconds, that a player is allowed to vote again if a vote was stopped early, either by aborting their own vote or by an admin aborting it.
  • vote_timeout - time, in seconds, until a vote ends early. if not enough votes have been made before this timer has passed, the vote ends prematurely and the tally is counted of the people that voted.
  • vote_wait - time, in seconds, a player must wait to make a new vote if the last vote got rejected. this is different from vote_stop in that it only takes effect if the vote was rejected in the tally, not if it was stopped manually.

utility commands​

with the addition to 1.1, the voting system also has a few utility commands that is useful for voting. these include:

restart
restarts the current map, which is useful for co-op as a way to reset the map if you don't want to expose map as a vote.

gametype
changes the current gametype. note that due to limitations in lua (notably the lack of gametype names being exposed), this does not change the current map, and will thus not work when switching to gametypes that the current map does not support.

nextlevel
similar to map, but queues up the next map rather than switching to it immediately. useful for ringslinger to set which map to play next without having to abort the current match.

increase and decrease
these two commands are meant to be used in combination with alias. like the name implies, they increase or decrease the current variable by a specified amount, which is useful as convenience votes when you don't want to set absolute values. an example on how they can be used:
Code:
alias extendmatchtime "increase timelimit 5"
alias reducematchtime "decrease timelimit 5"
addvote extendmatchtime
addvote reducematchtime

roll
this command allows players to roll a die. it takes two arguments: the amount of sides of each die and the total amount of dies to roll. for example, to roll 2 6-sided dice: roll 6 2

note that this command is optimized to process large numbers quickly, and as such ignores normal distributions. because of this, there's no bias against middle values with more than one die, unlike with real dice where values closer to the middle is more likely to occur than lower or higher values.

acknowledgements​

i want to thank everyone on the gaming den server for helping me test this thing out during public testing. too many people to keep track joined during this, including people that just joined out of curiosity as well as some of the servers' regulars that i see pretty much on a daily basis. thanks again for your help.

also, shoutouts to Xonotic for it's voting system that inspired this one; a lot of the design is similar or sometimes even identical to the one seen in Xonotic (hell, i even used it's source code as reference when writing this so the calculations would be right (yay for open source)), and it's all thanks to it's really well-designed and well thought-out system.
Author
Gouldron
Downloads
642
Views
1,889
Extension type
lua
File size
16.1 KB
MD5 Hash
20a6ffe4409d67505ce3a94eeceba868
First release
Last update

More resources from Gouldron

Share this resource

Latest updates

  1. 1.3 update

    been a hot minute since i've done anything lua, let alone an update. either way, here's a few...
  2. hotfix

    a hotfix to fix a bug introduced by 1.1, where it was possible to vote for commands that weren't...
  3. 1.1 update

    added a few utility command for common stuff you'd want for a voting system. forward slash (/)...

Latest reviews

Very nice voting system.
Upvote 0
Seems good
I'm currently not home so I will ask this for now
Can I enable people to vote to change the Gamemode?
Gouldron
Gouldron
not from this addon alone, but you could write lua script that changes the gametype via a command, then register that command in the voting system. thinking of it, though, it might be a good idea to make a secondary lua script that contains common commands that you'd want for voting.
Upvote 0
Back
Top