Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Vote System (UTILITY) #125

Closed
Chalwk opened this issue May 3, 2021 · 4 comments
Closed

Map Vote System (UTILITY) #125

Chalwk opened this issue May 3, 2021 · 4 comments

Comments

@Chalwk
Copy link
Owner

Chalwk commented May 3, 2021

Title: Map Vote System

Description:

This script is a drop-in replacement for SAPP's built-in voting system.

 - features -
 1). Cast and re-cast your vote.
 2). Ability to show more than 6 map vote options.
 3). Configurable messages.
 4). Limit how many times can a player re-vote.
 5). Full control over script timers:
	 * Time until map votes are shown (after game ends).
	 * Time until votes are calculated (after game ends).
	 * Time until map cycle (after PGCR screen is shown)

 - notes -
 1). You need to import your map vote settings from mapvotes.txt
 2). This script will disable SAPP's built-in map vote setting automatically.
 3). Map skipping will still work and the skip ratio is defined in the config.
 ----------------------------------------------------------------------------------------

         See config section for more information.

Download Link

CONFIGURATION:

-- Configuration Starts --
local MapVote = {

    -- Map skip setting:
    --
    -- map_skip is the percentage of people needed to skip the map.
    -- Set to 0 to disable map skipping entirely.
    -- Default: 60%
    map_skip = 60,
    --

    -- How many votes options to display when the game ends?
    amount_to_show = 5,
    --

    -- If true, players can re-cast their vote:
    re_vote = true,

    -- How many times can a player re-vote?
    re_vote_count = 1,

    -- If true, the player's console will be cleared each time we print vote options:
    clear_console = false,

    -- Most messages are configurable (edit them here):
    messages = {

        -- message alignment characters: "|l", "|r", "|c", "|t" = Left, Right, Center, Tab

        -- Message omitted when player votes for map:
        [1] = "|l%name% voted for [#%id%] %map% %msg%",
        --

        -- Message omitted when player re-votes (updates):
        [2] = "|l%name% updated their vote to [#%id%] %map% %msg%",
        --

        -- Map vote option format:
        [3] = "|l[%id%] %map% %msg%",
        --

        -- Map vote calculation messages:
        [4] = {
            "|l%map% %msg% won with %votes% vote%s%",
            "|lNo Votes! Picking %map% %msg%..."
        }
        --
    },

    ----------------------------------------------------------------------------------------
    -- I do not recommend changing these values:

    -- Time (in seconds) until we show map votes (after game ends)
    time_until_show = 7,

    -- Time (in seconds) until votes are calculated (after game ends):
    time_until_tally = 13,

    -- Time (in seconds) until map cycle (after PGCR screen is shown):
    map_cycle_timeout = 13,

    -- Vote options will be re-shown every "re_show_interval" seconds until timer reaches "time_until_tally"
    re_show_interval = 5,
    ----------------------------------------------------------------------------------------

    maps = {

        --[[

        =============================
        - TECHNICAL NOTES -
        =============================

        1). Configure the map votes in the following format: {map name, game mode, message}

        2). Map vote options will be seen in-game like this:

            Examples:
            [1] bloodgulch (ctf)
            [2] deathisland (ctf)
            [3] sidewinder (ctf)
            [4] icefields (ctf)
            [5] infinity (ctf)

        3). You can define custom game modes like this:

            { "bloodgulch", "MyCustomKing", "(Custom King)" },
            Example #2 (as seen in-game): [1] bloodgulch (Custom King)

        ]]

        --======================================--
        -- CONFIGURE MAP VOTES HERE --
        --======================================--
        { "bloodgulch", "ctf", "(ctf)" },
        { "deathisland", "ctf", "(ctf)" },
        { "sidewinder", "ctf", "(ctf)" },
        { "icefields", "ctf", "(ctf)" },
        { "infinity", "ctf", "(ctf)" },

        { "timberland", "ctf", "(ctf)" },
        { "dangercanyon", "ctf", "(ctf)" },
        { "beavercreek", "ctf", "(ctf)" },
        { "boardingaction", "ctf", "(ctf)" },
        { "carousel", "ctf", "(ctf)" },

        { "chillout", "ctf", "(ctf)" },
        { "damnation", "ctf", "(ctf)" },
        { "gephyrophobia", "ctf", "(ctf)" },
        { "hangemhigh", "ctf", "(ctf)" },
        { "longest", "ctf", "(ctf)" },

        { "prisoner", "ctf", "(ctf)" },
        { "putput", "ctf", "(ctf)" },
        { "ratrace", "ctf", "(ctf)" },
        { "wizard", "ctf", "(ctf)" }
    },

    -- A message relay function temporarily removes the server prefix
    -- and will restore it to this when the relay is finished:
    server_prefix = "**SAPP**"
}
-- Configuration Ends --
@Chalwk Chalwk added the new mod! label May 3, 2021
@Chalwk Chalwk self-assigned this May 3, 2021
@Chalwk
Copy link
Owner Author

Chalwk commented May 4, 2021

Updated with a fix for a bug (described below)

The bug:
Suppose we have an array of 7 maps but we want to show a maximum of 5 maps when the game ends.
At the end of game 1, the script will display the first 5 maps in the array.
At the end of game 2, the script will display the remaining 2 but not loopback and include the first 3 (for a total of 5) of the first group.

This has been fixed.

@Chalwk
Copy link
Owner Author

Chalwk commented May 5, 2021

May 06, 2021
Updated just now with some tweaks to the script documentation and corrected a couple of minor bugs.

@Chalwk
Copy link
Owner Author

Chalwk commented May 9, 2021

MAP VOTE SYSTEM UPDATES:
1). Added the option to limit how many times a player can re-vote (once by default).

2). In the case that all maps voted for have equal votes, the script will now pick a random one.

3). Added the option to clear the player's console each time we need to print the vote options.

4). Refactored a couple of functions for improved performance & updated script documentation.

@github-actions
Copy link

github-actions bot commented Jul 9, 2021

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant