Enhanced voting for Enemy Territory - Wolfenstein.
|Sanitize team specific vote when defender is not set.||a23d757, 21 Nov 2021|
This is a Lua module for Enemy Territory - Wolfenstein server introducing extended voting functionality and providing an easy way to define new commands.
- Create an empty
vote++.config.luafile (that's where the configuration goes).
Client interface does not reflect the casted vote, or it can incorrectly render as already casted without that being actually the case. You can fix that in ETPro by switching to patched qagame. It is not mandatory, the votes are casted anyway; it's only the yellow popup that's wrong.
All the configuration belongs to
Apart from defining commands, you can define any ET callback (like
et_RunFrame) and use any API (
et.* and stdlib).
Defining vote commands
Vote:new("nohw") :description("Disable heavy weapons") :pass("exec nohw.cfg")
This command can be executed as:
ref nohw (in server console or as an authenticated referee).
Vote:new(string): command name, can be defined as:
string <arg1> <arg2>
The module automatically validates number of passed arguments and prints a help message when not enough of them is given. There's a special reserved argument
<player>, which always resolves to a slot number. Caller can use part of name instead. When using string as argument to callback functions (see below), you can use:
<player:%s>, which resolves to a slot number or player name, respectively.
All arguments defined in the
Vote:new() constructor will be passed to callback functions (
:description(string): help text of the command.
:vote(string | function): this can be either a string or function called immediately after
callvotecommand. It's supposed to validate the arguments and return a vote string.
Vote:new("remove <player>") :vote("PUTSPEC <player:%s>") -- PUTSPEC ETPlayer
Vote:new("kill <player>") :vote(function(player) if math.random() < 0.5 then return false, "No, you're out of luck." -- you can optionally return error message end return string.format("KILL %s", et.gentity_get(player, "pers.netname")) end)
:pass(string | function): this will be called if the vote passes
:fail(string | function): this will be called if the vote fails
:percent(number): sets the percentage at which the vote passes, default:
:team(): makes the vote team only - this only works if the
<player>argument is specified in the constructor
:attacker(): makes the vote only available for attacking team
:defender(): makes the vote only available for defending team
Disabling vote commands
You can disable any or all the vote commands, including the built-in ones.
V.disable("*") -- disables all commands V.disable("warmupdamage") V.enable("kick")
ETAdmin can, under certain conditions, automatically cancel or pass votes. It does so by executing
passvote to server console. ETPro doesn't propagate this command to Lua modules, so you need to change it to
passvote++. Native functionality is preserved.