Vote (Old)

From EventScripts Community Encyclopedia

Contents

This is the old vote command [Eventscripts 1.2, 1.3]


Overview

Syntax: vote <command> <vote name> <parameters>

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Description

Creates and handles user votes and runs a block at the end of the vote.


Note: It doesn't expand server variables. Prefix the command with es to expand variables (es vote).

Parameters

  • command - tells what to do to your vote
  • vote name - unique name for the vote to be modified
  • parameters - command specific parameters


Commands

vote start <vote name> <time> <blockname> <question> <answer1> <answer2> [answer3] ... [answer9]

Creates a new vote in memory. You need to create a vote using this command before using any other commands on it.
vote stop <vote name>

Ends a vote from memory. This command will automatically be called if the vote time is over.
vote submit <vote name> <answer#>

Adds a user answer to the vote in memory.
vote menu <vote name> <userid>

Re-opens the vote menu for this user.
vote getstatus <variable> <userid>

Gets the vote status of a user. Seems to return the name of the vote as given in the vote command.

Examples

Example script using corelib's vote command:

addons/eventscripts/votetester/es_votetester.txt

block load
{
  // vote requires corelib
  es_load corelib
}
 
event es_client_command
{
  // every script that wants to do a vote needs to include a vote listener line in es_client_command
  vote listener
}
 
event player_say
{
  if (event_var(text) equalto "!voteboy") do
  {
    // syntax:
    // vote start <name> <expire-time> <block-to-run> <question> <option1> <option2> [option3] [option4] ... [option9]
    vote start voteboy 10 votetester/vote_done "What map do you want?" "de_dust" "cs_italy" "de_dust2" "scoutzknivez" "cs_office"
  }
}
 
// this is the block we configured to be called when the vote is over.
block vote_done
{
  if (server_var(vote_answertext) != 0) do
  {
    es_msg #green Vote done: Map will change in 5 seconds to server_var(vote_answertext)
    es_delayed 5 changelevel server_var(vote_answertext)
  }
  else do
  {
    es_msg #green Vote cancelled: not enough votes.
  }
}

Notes

  • Vote is only in EventScripts v1.1.1 or higher

See also

blog comments powered by Disqus