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

[TF2] Map Voting Tweaks (2015-11-24)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
nosoop
Veteran Member
Join Date: Aug 2014
Plugin ID:
4919
Plugin Version:
0.1.3
Plugin Category:
General Purpose
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
    2 
    Plugin Description:
    Take control of the TF2 map vote panel!
    Old 11-24-2015 , 03:31   [TF2] Map Voting Tweaks (2015-11-24)
    Reply With Quote #1



    Description:
    Changes the vote panel so it:
    1. Rewrites the workshop map name to a friendly display name (currently built for 1.7, so I can't take advantage of GetMapDisplayName). Also removes excluded maps (as determined by the MapChooser plugin).
    2. Hooks the callvote command, handling it if it's a NextLevel or ChangeLevel vote and resolving display names back into workshop names if necessary.
    3. Optionally overrides the vote call, allowing clients to use the NextLevel vote panel to nominate a map instead.
    ConVars:
    • sm_tfmapvote_version: Plugin version.
    • sm_tfmapvote_nominate (default true): Whether or not "next map" vote calls should be treated as map nominations.
    • sm_tfmapvote_exclude (default true): Whether or not recent maps (as determined by GetExcludeMapList) are removed from the vote panel.
    Things the plugin will clobber:
    The plugin modifies the user data of the first entry in the ServerMapCycle string table, which stores the map cycle for the voting panel. Honestly, I don't know if it's used for anything else. I've spent a long night testing the crap out of this plugin, and I can't find any other side effects of modifying that table, so it should be okay.

    This plugin will try to clean up and restore something that resembles the original ServerMapCycle table when unloaded, so in the event that A VERY BAD THING™ happens, you can unload it and things should act like the plugin was never there. I'm pretty sure that the table gets regenerated on map change, too.

    Dependencies:
    Currently requires MapChooser to perform map nominations and get map exclusions. I'll have to see if this can be an optional dependency eventually.

    Changelog:
    • 0.1.3 (2015-11-24, the "why am I up at six in the morning again" edition)
      • Removed hardcoded stringtable index and added support for ChangeLevel.
    • 0.1.1 (2015-11-23, the "wait, it's not October" edition) (4)
      • Initial public release.
    Source code on Github.
    Attached Files
    File Type: sp Get Plugin or Get Source (tf_map_voting_tweaks.sp - 1270 views - 11.4 KB)

    Last edited by nosoop; 11-24-2015 at 09:02. Reason: my post keeps getting eaten send help also 0.1.3
    nosoop is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 11-25-2015 , 14:12   Re: [TF2] Map Voting Tweaks (2015-11-24)
    Reply With Quote #2

    I know of one plugin that won't work with this:

    NativeVotes 1.1 has an entire infrastructure (natives, implementation) in place to manage the TF2 callvote menu. 1.0 did as well, but then Valve changed the VoteSetup usermessage and forced me to rewrite it.

    MapChooser Extended 1.11, or more accurately its subplugins Nominations Extended and RockTheVote Extended, hook into the previously mentioned NativeVotes callvote infrastructure, specifically for the NextLevel and ChangeLevel vote types.

    None of the above plugins have had a public release yet. NativeVotes 1.1 was close to release, but then I decided to add support for No Vote like the standard vote system and it still needs testing.

    On a side note, the ServerMapCycle you mention is likely used by the listmaps command. I'm pretty sure it's populated with the maps from the file mentioned in the mapcyclefile cvar.

    It's also likely used if you're not using a third-party map voting system, but that's not really relevant here.
    __________________
    Not currently working on SourceMod plugin development.

    Last edited by Powerlord; 11-25-2015 at 14:51.
    Powerlord is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 11-26-2015 , 00:09   Re: [TF2] Map Voting Tweaks (2015-11-24)
    Reply With Quote #3

    Quote:
    Originally Posted by Powerlord View Post
    NativeVotes 1.1 has an entire infrastructure (natives, implementation) in place to manage the TF2 callvote menu. [...]
    Looks pretty slick!
    I'll probably trim it down to just resolving map names and rewriting the mapcycle once NV1.1 is out proper.

    Regarding the aside, just checked; the listmaps command doesn't appear to pull its output from ServerMapCycle on execution -- running the command shows all the maps I have from mapcyclefile as they are in the short "workshop/id" format, and it doesn't modify the vote options in the vote menu again. Other built-in commands don't fall for the rewritten map names, so it'll remain a mystery for now.
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
    nosoop is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 03-07-2016 , 20:11   Re: [TF2] Map Voting Tweaks (2015-11-24)
    Reply With Quote #4

    OK, I may need to do more experiments with this StringTable. If it exists on CS:GO, it has occurred to me that this will let you read the MapGroup information.

    Of course, if TF2 gets the ability to use workshop map collections in the future, it might be useful for TF2 as well.
    __________________
    Not currently working on SourceMod plugin development.
    Powerlord is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 07-23-2016 , 12:03   Re: [TF2] Map Voting Tweaks (2015-11-24)
    Reply With Quote #5

    OK, so I have a new beta version of NativeVotes out that has a feature inspired by this plugin (mainly because NativeVotes and this plugin don't work well together).

    My implementation was pretty much done from scratch.

    Now, having said that, here's a few things of note that I ran into:
    1. TF2's client always organizes its NextLevel and ChangeLevel items in alphabetical order.
    2. On rare occasions, the game writes the ServerMapCycle stringtable late. That is, it would write to it after my OnConfigsExecuted+RequestFrame ran and overwrote my changes. I had to add a 1 second timer after OnConfigsExecuted instead before I wrote to the stringtable.
    3. Occasionally, the server hadn't finished loading the names of all my workshop maps (and I only have 11) by the time OnConfigsExecuted+RequestFrame ran for the first map. This was fixed by the same timer as the above problem.
    4. SetStringTableData's length needs to be the strlen+1 (or something similar, the ImplodeStrings and strcopy functions return bytes they put in strings) of what you're writing as the game actually allocates that many bytes in the stringtable. Also, SourceMod gets grumpy if you try to allocate dynamic strings larger than a certain size.
    5. I wrote some new code to explode/implode strings to/from ArrayLists and StringMaps. Made it easier to pass these between plugins.

    OK, now glancing at the code used in this plugin, you can use the GetFeatureStatus function to find out if a particular native is present. For instance:

    Code:
    if (GetFeatureStatus(FeatureType_Native, "GetMapDisplayName") == FeatureStatus_Available)
    {
        // GetMapDisplayName can be used here
    }
    However, if you do this, you also have to use MarkNativeAsOptional on the same function name in AskPluginLoad2.
    __________________
    Not currently working on SourceMod plugin development.
    Powerlord 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 17:25.


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