Raised This Month: $12 Target: $400
 3% 

Custom Votes v0.5.6 (1/07)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
chundo
Senior Member
Join Date: May 2008
Plugin ID:
408
Plugin Version:
0.5.6
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    95 
    Plugin Description:
    Allow easy addition of custom votes using configuration files
    Unapprover:
    Reason for Unapproving:
    Many RTEs, author inactive.
    Old 06-03-2008 , 00:11   Custom Votes v0.5.6 (1/07)
    Reply With Quote #1

    Custom Votes v0.5.6 (1/07)

    Custom votes allows you to initiate votes defined in a configuration file, without requiring any additional plugin coding. Votes will execute server actions depending on the result.
    The intent is to easily allow other plugin authors to add custom votes just by dropping a config file in the customvotes configuration directory. What Custom Admin Menus (formerly dynamicmenu/Super Menu) does for menus, Custom Votes does for voting.

    Quick Install:
    Unzip customvotes.zip into your server root. Vote configurations are stored in configs/customvotes, and show up in the "Voting Commands" admin menu.
    Included Vote Configurations:
    Normal Votes:
    changelevel - Vote to change the map immediately.
    extend - Vote to extend the map 20 minutes.
    scrambleteams - Vote to scramble the teams and restart the round.
    setnextmap - Vote to set the next map.
    crits - Vote to turn crits on or off.
    Chat Votes (replaces PlayersVotes, do not use both together without disabling these votes in configs/customvotes/playervotes.vote.cfg):
    voteban - Vote to ban a player. Type "voteban" in chat.
    votekick - Vote to kick a player. Type "votekick" in chat.
    votemap - Vote to change the map. Type "votemap" in chat.
    votealltalk - Vote to turn alltalk on or off.
    This is all you need to get started. For changes since the last version, see the change log at the bottom of this post. Continue reading for more comprehensive usage documentation.

    Detailed Usage Documentation

    CVars:
    All cvars have sane defaults, and most admins will not need a separate configuration file for this plugin.
    sm_cvote_version - Plugin version.
    sm_cvote_showstatus - Show vote results to players as they occur. "0" is off, "1" displays aggregate results in a side panel, "2" displays votes anonymously in chat, "3" displays votes with player names in chat. (default 1)
    sm_cvote_triggers - Allow votes to be triggered by regular chat keywords (i.e. "votegravity".) (default 1)
    sm_cvote_triggerdelay - The delay in seconds between non-admin initiated votes. (default 60)
    sm_cvote_mapdelay - The delay in seconds after a map starts before a vote can be initiated. This can be overridden on a per-vote basis in the vote configuration. (default 0)
    sm_cvote_executedelay - The delay in seconds after a vote succeeds before the resulting command is executed. (default 3.0)
    sm_cvote_minpercent - The minimum percentage needed for a vote to be considered successful. This can be overridden on a per-vote basis in the vote configuration. (default 60)
    sm_cvote_minvotes - The minimum votes needed for a vote to be considered sucessful. This can be overridden on a per-vote basis in the vote configuration. (default 0)
    sm_cvote_adminonly - Only allow admins to initiate votes (except chat votes), even if they don't define an "admin" configuration parameter.
    sm_cvote_resetonmapchange - Clears all pending votes on map change (as opposed to retaining the status of chat-votes like votekick, voteban, etc). (default 0)
    Custom Votes also uses the value of sm_vote_delay (from basevotes) as a minimum delay between votes.
    Admin Commands:
    sm_cvote <votename> <params>
    Initiates the named vote. If no name is specified, a menu of valid votes will be presented. Extra parameters can be passed from the console if the vote requires it (see "Parameters" below), but if omitted the player will be prompted for them via menus. This can also be launched from chat with "/cvote <votename> <params>".
    sm_cvote_reload
    Check configuration directory for changes.
    Console Commands:
    sm_votemenu
    Displays a menu of votes the player is allowed to initiate. !votemenu in chat.
    Configuration:
    Custom Votes loads every configuration file it finds in configs/customvotes. For example, if you wanted to add a gravity vote, you could add "gravity.vote.cfg" to addons/sourcemod/configs/customvotes/. The section name should be a unique name that is used to identify the vote. See the "Configuration Examples" section below for samples, or look at the included vote configurations in the attached customvotes.zip.

    Vote configuration:
    Required attributes:
    title - The vote title that will display to users when it is initiated.
    type - The type of vote (see "Vote Types" below.) Defaults to "list".
    cmd - The command to execute when the vote succeeds. Parameters are specified by #1, @2, etc. (see "Parameters" below.)
    options (required for list votes only) - A KeyValues subsection that contains key/value pairs for the vote options to be displayed.
    Optional attributes:
    admin - The name of a server command that determines who can initiate this vote. For example, if this is set to "sm_kick", only admins with the "kick" permission can initiate this vote.
    target - The users that this vote will display to. In addition to the standard target strings, you may also use "@admins". For a "chat" type vote, Custom Votes will only register the votes of players that are part of the target string.
    delay - The delay in seconds betweens two votes of this type.
    mapdelay - The delay in seconds after a map starts before this vote can be initiated.
    percent - The minimum percentage of votes the winning choice needs to have to be considered the winner.
    abspercent - The minimum percentage of all in-game players that the winning choice needs to pass. This differs from percent because it looks at all in-game players, rather than just the ones that chose to vote.
    votes - The minimum number of votes the winning choice needs to have to be considered the winner.
    approve - Who must approve the vote result before it is finalized. Can be either "sender", "admins", or "none." Defaults to "none".
    Launch parameters:
    params - A KeyValues subsection specifying the type of each numbered parameter. These are parameters that must be passed to the vote, and are not displayed to voters. A parameter can take the form of a numbered subsection specifying the possible values and descriptions (similar to "options" section for list-type votes), or a single numbered parameter type to use built-in parameter types. See the "Parameters" section below for examples. Built-in parameter types are:
    mapcycle - Parameter is a map from the mapcycle. Custom mapcycles can be used by adding a section to maplist.cfg called "sm_cvote <votename>".
    player - Parameter is a single player
    group - Parameter is a group of players
    groupplayer - Parameter is a single player OR group of players.
    onoff - Either "on" (1) or "off" (0).
    yesno - Same as onoff, except the prompt menu will display "Yes" or "No" instead of "On" or "Off".
    Chat triggers:
    trigger - A KeyValues subsection defining the chat-keyword trigger for this vote. The following options control how the chat trigger works:
    command - The chat keyword that triggers the vote
    delay - The amount of time that must pass between chat-triggered votes of this type. Equivalent to the previous (now deprecated) "playerdelay" parameter.
    notice - The message that will be printed to chat as users enter triggers (useful when requiring triggers from multiple users, see "percent" and "count" below). "%u" is replaced with the triggering player's name. Uses "title" if omitted.
    percent - The minimum percent of current connected users that must enter this trigger for the vote to launch. Defaults to 0.
    count - The minimum number of current connected users that must enter this trigger for the vote to launch. Defaults to 0.
    expires - How long (in seconds) before a user's vote trigger is expired (so that vote triggers do not build infinitely). Users that disconnect have their votes removed automatically. Defaults to 300 (5 minutes).
    Vote Types:
    onoff - Displays a simple "On" or "Off" vote, which returns the values "1" or "0" as the result parameter.
    confirm - Displays a simple "Yes" or "No" vote. If "Yes" wins, the command will be executed (although no result parameter is returned); if "No" wins, nothing is executed.
    list - Displays a vote using the name/value pairs from the "options" subsection for the vote. Option keys and values can also use expression substitution (and parameter substitution, if parameters are passed from the console.) The winning option value is returned as the result parameter.
    chat - The vote is carried out using only chat triggers. A trigger section must be defined, and once the trigger threshold is reached, the command is executed without a menu vote.
    Chat Triggers:
    If sm_cvote_triggers is on, you can specify chat keywords to launch a vote. Triggers are significantly different in 0.5 from 0.4, in that they have separate vote percent/vote count minimums from the vote itself. As a result if a "trigger" section exists, it ignores the "admin" parameter when deciding who can use the trigger in order to enable PlayersVotes-style chat voting. If you want your admins to directly launch votes from chat, they must now use the "/cvote <votename>" method. See the configuration examples section below. If a vote requires additional parameters, they can also be passed in chat (i.e. "votenextmap cp_badlands".)
    Parameters:
    Vote titles, vote commands, trigger notices, option keys and option values can all use parameter replacements. The actual vote result will always be the last parameter. Similar to Custom Admin Menus, parameters take the format #1, #2, #3, etc. (or @1, @2, @3 to display parameters unquoted.)

    Example: "sm_setnextmap #1"

    If any parameters are defined in the "params" section of the vote configuration, sm_cvote will require that you pass in additional parameters from the console, or it will prompt you for them via menus. For example, take the following command/params example:

    Code:
    "cmd"        "sm_ban #1 #2 votedbanned"
    "params"
    {
        "1"      "player"
        "2"
        {
            "5"      "5 minutes"
            "30"     "30 minutes"
            "60"     "60 minutes"
            "0"      "Permanently"
        }
    }
    This would require that you pass in the userid (#1) and the ban time parameter (#2). If you omit any parameters, Custom Votes will ask you to select them via menus.

    Note that with "confirm" type votes (Yes/No), the vote does not produce a parameter from the result, it only determines whether to execute the command string or not. Because of this, all parameters used in a "confirm" vote need to be defined in the "params" section (even the last one.)
    Expressions:
    In addition to parameter replacement, Custom Votes has a handy expression replacement feature, which allows you to insert CVar values. Vote titles, vote commands, trigger notices, option keys and option values can all contain expressions.

    Example title: "Turn all talk {!sv_alltalk|onoff}?"

    This would parse to "Turn all talk on?" or "Turn all talk off?", depending on the current value of sv_alltalk.

    Syntax: {[!]cvar_name[|modifier(s)]}

    An initial "!" reverses the value of boolean CVars (useful for toggle votes). Any modifiers after the CVar determine how the variable displays. Current modifiers are "onoff", "yesno", "upper", "lower", and "capitalize." Multiple modifiers can be strung together (i.e. {sv_alltalk|onoff|capitalize}).
    Configuration Examples:
    Vote parameters:
    Code:
    "changelevel"
    {
        "title"        "Change map to #1?"
        "type"         "confirm"
        "admin"        "sm_setnextmap"
        "cmd"          "changelevel #1"
        "params"
        {
            "1"        "mapcycle"
        }
    }
    Chat Vote:
    Code:
    "voteban"
     {
         "title"         "Ban #1 for 30 minutes?"
         "type"          "chat"
         "cmd"           "sm_ban #1 30 \"Banned by vote.\""
         "trigger"
         {
             "command"   "voteban"
             "notice"    "%u voted to ban #1"
             "percent"   "75"
             "count"     "4"
         }
         "params"
         {
             "1"         "player"
         }
     }
    List Vote:
    Code:
    "gravity"
     {
         "title"        "How much gravity should we use?"
         "type"         "list"
         "cmd"          "sm_gravity #1"
         "options"
         {
             "200"      "Very Low"
             "400"      "Low"
             "800"      "Normal"
             "1600"     "High"
             "3200"     "Very High"
         }
     }
    For more vote configuration examples, see the attached configuration files in customvotes.zip.
    Integration With Admin Menu:
    Custom votes will automatically show up in the "Voting Commands" admin menu. Votes will prompt the user for any extra parameters they require. For sorting purposes (with adminmenu_sorting.txt), menus have the identifier of "cvote_<votename>", where <votename> is the section name defining the vote - so for example, for the first example in the Configuration Examples section above, the menu identifier would be "cvote_changelevel".
    Installing:
    customvotes.smx -> addons/sourcemod/plugins/
    customvotes.sp -> addons/sourcemod/scripting/
    customvotes.phrases.txt -> addons/sourcemod/translations/
    *.vote.cfg -> addons/sourcemod/configs/customvotes/

    Or, you can just unzip the attached customvotes.zip into your server root.
    Changelog:
    0.1 - Initial release
    0.2 - Added chat triggers
    - Added vote delay configuration
    - Bugfix: some votes were inheriting configuration values from other votes
    0.3 - Added menu prompts for vote parameters (maps, groups/players, etc)
    - Added votemenu command
    - Fixed "player" parameters ignoring immunity
    0.4 - Added admin menu integration
    0.4.1 - Fixed bug where setting sm_cvote_showstatus to 1 resulted in terminating the vote after a single vote
    - Added detailed error logging for configuration file errors
    - Commented out "voteban", "votekick", and "votemap" chat triggers in basevotes.vote.cfg by default to avoid conflicts with PlayersVotes.
    0.5 - Revamped chat triggers to allow PlayersVote-style votes
    - Added playersvotes.vote.cfg to integrate PlayersVotes functionality. IF YOU USE THIS CONFIGURATION, DISABLE THE PLAYERSVOTES PLUGIN.
    - Significantly modified vote configuration parameters, although it should be backwards-compatible with 0.4.1.
    - New vote type (chat) and vote parameter types (yesno, onoff).
    - Added sm_cvote_reload and auto-reloading on map change
    - Fixed vote status panel blocking weapon switches
    - Hide vote status panel until vote completes if user hits "0".
    - Added "Quick Start" section in this post to avoid scaring people with excessive documentation.
    0.5.1 - Fixed bug parsing "command"
    0.5.2 - Fixed targeting logic for non-admins
    - Added list-style parameters
    0.5.3 - Fixed votes stalling if they required approval
    - Reset current vote pointer before executing command to allow chaining votes together
    0.5.4 - Fixed bug resulting in multiple event hooks, causing chat spam and potentially misbehaving votes
    0.5.5 - Added abspercent configuration directive
    - Added 3 second delay (configurable via sm_cvote_executedelay) before executing a command after a successful vote
    - Added sm_ban_auto command as a helper for the included voteban vote (handles banning disconnected players as well)
    - Fixed custom mapcycle feature
    0.5.6 - Fixed security hole with !votemenu command
    - Added "target" support to chat votes
    - Fixed a problem were votes were improperly disabled
    Credits:
    Developed by chundo.
    Idea inspired by pRED's custom admin menus.
    Thanks to The Resident for PlayersVotes and providing me with chat voting requirements for voteban/votekick/votemap.
    Attached Files
    File Type: txt customvotes.phrases.txt (2.4 KB, 8806 views)
    File Type: sp Get Plugin or Get Source (customvotes.sp - 13147 views - 58.5 KB)
    File Type: zip customvotes.zip (49.1 KB, 19731 views)

    Last edited by chundo; 01-07-2009 at 18:24. Reason: New version
    chundo is offline
    FunTF2Server
    Veteran Member
    Join Date: Apr 2008
    Old 06-03-2008 , 04:20   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #2

    I want to make it for players on my server can call a vote to turn alltalk on and off, and also turn friendly fire on and off, when no admin is present... that way it's a democracy and the majority can get what they want for most people are happy, even when an admin is not on the server.

    can I do that with this plugin, if so, how?

    I want it for when a player types vote_ff in the chat, it will call a vote to turn friendly fire on and off. Also vote_alltalk to turn alltalk on and off. Also I want to make it for a vote for each one can only be called once every 5 minutes.
    __________________
    FunTF2Server is offline
    chundo
    Senior Member
    Join Date: May 2008
    Old 06-03-2008 , 11:20   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #3

    Yes, it's just a console command so anyone can run it - it does its own permission checking based on the "admin" attribute of the vote. If you omit that attribute, any user can initiate it.

    For example, just setup an alltalk vote like in example2.vote.cfg but omit the "admin" attribute, and users will be able to launch it with "/cvote alltalk" in chat.

    I'm considering adding a chat alias option to the config as well that would allow you to launch votes with a simple chat keyword - "votealltalk", "voteff", etc.

    Right now I use the global vote delay (controlled by the sm_vote_delay CVar). I will look into adding a longer delay for user votes though. Do you mean one vote period per five minutes, or one vote of each TYPE per five minutes?

    Last edited by chundo; 06-03-2008 at 11:34.
    chundo is offline
    ottobohn
    Senior Member
    Join Date: Sep 2007
    Old 06-03-2008 , 11:39   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #4

    Perfect.

    Otto
    n00bsalad.net
    ottobohn is offline
    FunTF2Server
    Veteran Member
    Join Date: Apr 2008
    Old 06-03-2008 , 17:36   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #5

    Quote:
    Originally Posted by chundo View Post
    I'm considering adding a chat alias option to the config as well that would allow you to launch votes with a simple chat keyword - "votealltalk", "voteff", etc.
    Yes please add that, it would be awesome. A lot of users can be n00bs and don't have console enabled, so won't be able to call votes, and can't figure out how to open console.

    Quote:
    Originally Posted by chundo View Post
    Right now I use the global vote delay (controlled by the sm_vote_delay CVar). I will look into adding a longer delay for user votes though. Do you mean one vote period per five minutes, or one vote of each TYPE per five minutes?
    One vote of each type per 5 minutes, or however many minutes I set with an integer value.

    Maybe we could configure it for the delay is per type of vote in the config file, like alltalk vote could only be called every 5 minutes, friendly fire vote can only be called every 10 minutes, mapchange vote can only be called every 30 minutes, etc.
    __________________
    FunTF2Server is offline
    bakaideda
    Junior Member
    Join Date: Mar 2008
    Old 06-04-2008 , 08:09   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #6

    I want that players write something in chat and trigger vote for something...
    For example: DEATHMATCH... But when admins are not on server.
    I started with this but I dont know what they must write in chat to trigger this voting...

    Code:
    "Votes"
    {
        "DM VOTING"
        {
            "title"        "DEATHMATCH {!cssdm_enabled|onoff}?"
            "admin"      "sm_kick"
            "target"     "@all"
            "percent"   "70"
            "type"        "confirm"
            "cmd"         "cssdm_enabled {!cssdm_enabled}"
        }
    }
    bakaideda is offline
    DJ Tsunami
    DJ Post Spammer
    Join Date: Feb 2008
    Location: The Netherlands
    Old 06-04-2008 , 10:54   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #7

    As chundo said, it's currently not yet possible to trigger a vote through chat. This will be added in 0.2 (as the first post says).

    @chundo: awesome plugin, I was actually thinking of doing this myself but couldn't figure out what the best way would be to do it. I hope this will become part of the SM core so we can do away with the stock voting plugins, and can easily make custom votes too.

    Idea: make a timeleft option to run a vote x minutes before the map ends. Would make it possible to replace rtv
    __________________
    Advertisements | REST in Pawn - HTTP client for JSON REST APIs
    Please do not PM me with questions. Post in the plugin thread.

    Last edited by DJ Tsunami; 06-04-2008 at 10:57.
    DJ Tsunami is offline
    chundo
    Senior Member
    Join Date: May 2008
    Old 06-04-2008 , 11:10   Re: Custom Votes v0.1 (6/2)
    Reply With Quote #8

    bakaideda -

    If you remove the "admin" parameter in the vote, it makes it so anyone can launch it. And although you can't specify a user-friendly chat keyword (yet), you can launch it from chat with the standard SourceMod method, i.e.:

    /cvote "DM VOTING"

    (Assuming the space in the name doesn't throw it off, haven't tested that.)

    Thanks DJ Tsunami. I've added the chat keywords (and a few other features) to the Todo list for v0.2, which will be out this week yet. Closer custom admin menu integration is planned for 0.3 (allowing cvote to prompt the user for required parameters via menus when none are given).
    chundo is offline
    chundo
    Senior Member
    Join Date: May 2008
    Old 06-05-2008 , 12:26   Re: Custom Votes v0.2 (6/5)
    Reply With Quote #9

    Ok, chat triggers and vote delays are added in v0.2.
    chundo is offline
    FunTF2Server
    Veteran Member
    Join Date: Apr 2008
    Old 06-05-2008 , 15:40   Re: Custom Votes v0.2 (6/5)
    Reply With Quote #10

    thx so much chundo you are our hero.

    can anyone make me a sample cfg for votekick and voteban that anyone can call with exactly those keywords?

    i already made the voteff and votealltalk which is awesome but i cant figure how to get the votekick and voteban working, oh and votemap
    __________________
    FunTF2Server is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 20:43.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode