From EventScripts Community Encyclopedia
|
Overview
Syntax: vote <command> [votename] <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
- votename - unique name for the vote to be modified
- parameters - command specific parameters
Commands
- vote create
<votename> <callback-blockname> [vote-callback-blockname]
- Creates a new vote in memory. callback-blockname will be executed at the end of the vote. vote-callback-blockname will be executed everytime a user votes. You need to create a vote using this command before using any other commands on it.
- vote delete
<votename>
- Completly removes a vote from memory. You should only call this command if you want to delete everything related to this vote!
- vote exists
<return-var> <votename>
- Checks if the provided votename exists. Returns 1 if true and 0 if false.
- vote isrunning
<return-var> <votename>
- Checks if the provided votename is started and running. Returns 1 if true and 0 if false.
- vote setquestion
<votename> "<question>"
- Sets the question of the provided vote to question.
- vote setanswer
<votename> <#> "<answer>"
- Sets the answer at index # of the provied vote to answer.
- vote addanswer
<votename> "<answer>"
- Adds an answer to the provided vote.
- vote remanswer
<votename> <#>
- Removes the answer at index # from the provided vote.
- vote start
<votename> <time>
- Starts the provided vote with a timeout of time seconds.
- vote stop
<votename> [cancel]
- Stops the provided vote. You can alternativly cancel it by providing a second parameter.
- vote send
<votename> <userid> [force]
- Manualy resend the vote menu to the provided userid. If you also want it to show up again if the user voted already, provide a third parameter to force the menu to open.
- vote submit
<votename> <userid> <#> [force]
- Simulates that the provided userid voted for answer #. If you also want it to vote again if the user voted already, provide a third parameter to force the vote. Be careful! If the user still has the menu the answer could get overwritten again!
- vote getvotes
<return-var> <votename> [answer]
- Returns how much votes already have been submitted by the users. If you provide an answer it will return the votes for that answer.
- vote gettimeleft
<return-var> <votename>
- Returns the remaining time for the provided vote in seconds. 0 means that the vote is already finished or finishes within the next second.
Examples
Example vote popups:
Made with Vote System Addon by [NATO]Hunter.
Example script using vote command:
addons/eventscripts/vote/votetest/es_votetest.txt
// simple vote test script for vote command v0.4.4
//
block load
{
vote create funnyvote "vote/votetest/funnyvote" "vote/votetest/funnyvote_submit"
vote setquestion funnyvote "Is this a funny vote?"
vote addanswer funnyvote "Yes"
vote addanswer funnyvote "No"
vote remanswer funnyvote 1
vote setanswer funnyvote 1 "Yes!"
vote start funnyvote 120
}
block unload
{
vote stop funnyvote
vote delete funnyvote
}
block funnyvote_submit
{
// results:
// _vote_name = Name of the vote
// _vote_id = ID of the submitted answer
// _vote_text = Text of the submitted answer
// _vote_userid = UserID that submitted the answer
es_getplayername _tempcore server_var(_vote_userid)
es_msg #multi #lightgreen server_var(_tempcore) has voted server_var(_vote_text) #green[#lightgreen server_var(_vote_id) #green]!
}
block funnyvote
{
// results:
// _vote_name = Name of the vote
// _vote_id = ID of the winning answer
// _vote_text = Text of the winning answer
// _vote_count = Votes of the winning answer
// _vote_percent = Percentage of the winning answer
// _vote_votes = Total votes
// _vote_tie = 1 if there would be two or more winning answers and 0 if there is only one winning answer
// _vote_canceled = 1 if the vote was canceled and 0 if it was normaly stopped
es_msg #multi #greenAnswer#lightgreen server_var(_vote_text) #green[#lightgreen server_var(_vote_id) #green] has won with#lightgreen server_var(_vote_count) #greenof#lightgreen server_var(_vote_votes) #greenvotes [#lightgreen server_var(_vote_percent) %#green]!
ifx true(_vote_tie) do
{
es_xmsg #green The vote was tied!
}
ifx true(_vote_cancel) do
{
es_xmsg #green The vote was canceled!
}
}
Notes
- In EventScripts v1.5 the syntax has changed. If you want to see the v1.3 syntax visit Vote (Old)
- The old syntax is not supported in v1.5 as the command has changed to make use of the optional popup library.
- Every _ in votename's are changed to - (Please do not make use of this as it can be changed sometimes!)
See also
|
|