Monthly Target: $400 Donations: $23
 5% 

Dynamic Map Rotations (Nextmap Based on # of Players, Time, etc)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
FLOOR_MASTER
Senior Member
Join Date: Mar 2008
Plugin ID:
320
Plugin Version:
0.7
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Approver:
    Plugin Description:
    Dynamically alters the map rotation based on server conditions.
    Servers with this Plugin:
    7 
    Old 03-20-2008 , 21:41   Dynamic Map Rotations (Nextmap Based on # of Players, Time, etc)
    Reply With Quote #1

    Dynamic Map Rotations is a plugin I wrote to allow me to automatically alter the map rotation based on the current server conditions. With Dynamic Map Rotations, you can skip maps based on the number of players on the server or the time of day, and it's easy to add more conditions.

    Dynamic Map Rotations replaces nextmap.smx but reproduces the in-game "nextmap" functionality and the sm_setnextmap command.

    For brevity, I'll sometimes use "DMR" in place of dynamic map rotations.

    Configuration
    • dmr_file (default "dmr.txt")
      • Specifies the filename your DMR is stored in. The default filename resolves to orangebox/tf/dmr.txt in TF2, for example.
    • sm_nextmap
      • Specifies the current nextmap. This updates every minute and should be considered read-only.

    Commands
    • nextmap
      • This is an in-game chat trigger that displays the current nextmap, based on server conditions.
    • nextmaps
      • This is an in-game chat trigger that displays the next 5 maps, based on server conditions.
    • sm_setnextmap <mapname>
      • Force the specified mapname (e.g. "sm_setnextmap cp_dustbowl") to be the next map. After the forced nextmap is run, the rotation continues from where it left off (no maps are skipped).
    • sm_unsetnextmap
      • If you've used sm_setnextmap to force a nextmap, this command will undo that action and allow the DMR to proceed uninterrupted.
    • sm_reloaddmr
      • Reload your Dynamic Map Rotation if you've made any changes to it. Also display the current status of the plugin.
    Dynamic Map Rotations
    Dynamic map rotations are essentially keyvalues structures. I'll go through an illustrative example of how to create a simple DMR. Let's begin with a simple basic mapcycle.txt:
    Code:
    cp_gravelpit
    cp_well
    cp_dustbowl
    Here's an equivalent DMR:
    Code:
    "rotation"
    {
        "start"    "10"
        "10"
        {
            "map"            "cp_gravelpit"
            "default_nextmap"    "20"
        }
        "20"
        {
            "map"            "cp_well"
            "default_nextmap"    "30"
        }
        "30"
        {
            "map"            "cp_dustbowl"
            "default_nextmap"    "10"
        }
    }
    There are several things to note about the DMR:
    • The entire keyvalues structure is called "rotation"
    • Every map is its own section with an arbitrary section name. In this case, the names are "10", "20", and "30", but they could easily be the mapnames themselves or whatever you want.
    • There is a "start" keyvalue pair that indicates the first map in the rotation.
    • Within each section is a "map" keyvalue pair whose value is the actual name of the map.
    • Within each section is a "default_nextmap" keyvalue pair. The value points to the section of the nextmap. For example, notice how in section 30 (cp_dustbowl), the default_nextmap is section 10 (cp_gravelpit).
    The above DMR looks like:

    Now let's say we want to skip ctf_well when the number of players on the server is <= 12. The corresponding DMR looks like:
    Code:
    "rotation"
    {
        "start"    "10"
        "10"
        {
            "map"            "cp_gravelpit"
            "default_nextmap"    "20"
             "30"
            {
                "players_lte"    "12"
            }
        }
        "20"
        {
            "map"            "cp_well"
            "default_nextmap"    "30"
        }
        "30"
        {
            "map"            "cp_dustbowl"
            "default_nextmap"    "10"
        }
    }
    Notice the subsection added within section 10 (cp_dustbowl). This is called a conditional nextmap. Basically, the red highlighted section can be read as "if the number of players is lte (less than or equal to) 12, then the nextmap is section 30 (cp_dustbowl)". If the conditional nextmap isn't true, which in this case means there are more than 12 players on the server, then the default_nextmap is used as the next map. Visualized, this looks like:

    One more example. Let's add cp_badlands to the rotation and throw in a few more conditional nextmaps:
    Code:
    "rotation"
    {
        "start"    "10"
        "10"
        {
            "map"            "cp_gravelpit"
            "default_nextmap"    "20"
            "30"
            {
                "players_lte"    "12"
            }
    
        }
        "20"
        {
            "map"            "ctf_well"
            "default_nextmap"    "30"
            "bdlnds"
            {
                "players_lte"    "10"
                "time_lte"    "11:00"
            }
            "10"
            {
                "players_lte"    "10"
            }
        }
        "30"
        {
            "map"            "cp_dustbowl"
            "default_nextmap"    "10"
        }
    
        "bdlnds"
        {
            "map"            "cp_badlands"
            "default_nextmap"    "30"
        }
    }
    Before I discuss it, here is the visualization:

    First, notice how I used the section name "bdlnds". Remember that section names are arbitrary -- I could have just been consistent and chosen "40" or chosen anything at all.

    Let's look closely at section 20 (ctf_well). There are two conditional nextmaps and a default_nextmap. The first condition reads "IF the number of players <= 10 AND the current server time is <= 11AM, THEN the next map is section bdlnds (cp_badlands)". The second condition reads "IF the number of players <= 10 THEN the next map is section 10 (cp_gravelpit). If none of the conditional nextmaps are true, then the nextmap is the default_nextmap: section 30 (cp_dustbowl).

    Conditional nextmaps are evaluated in the order they're written, and the first one that is true is taken. So in the case of ctf_well, if the number of players were, for example 8, and it was 1AM, then the next map would be cp_badlands. If the number of players were 8 and it was 2PM, then the next map would be cp_gravelpit. It's really pretty straightforward!

    Automated DMR Generator
    Understandably, typing up a DMR is a pain. I've written a simple web tool to help get you started as well as visualize your DMR.
    Simply paste your mapcycle.txt into the top text box to generate the basic DMR. You can then modify it to add custom conditions. You can use the bottom text box to create a visualization of your DMR similar to the example images you've seen in this post.

    Custom Conditions
    • players_lte - the number of players on the server is less than or equal to the specified number
    • players_gte - ditto, but greater than or equal to
    • time_lte - the current server time is less than or equal to the specified time, in 24-hour "h:mm" format
    • time_gte - ditto, but greater than or equal to
    • day_eq - the day is currently a certain day of the week, where the day is specified with m, t, w, r, f, s, and u for Monday, Tuesday, etc. You can specify multiple days. For example, "day_eq" "mwf" will be true if the day is Monday, Wednesday, or Friday. "day_eq" "u" will be true if the day is Sunday.
    • day_neq - ditto, but if the day is NOT a certain day of the week
    Please send me your ideas for new custom conditions to add.

    Installation
    1. Move nextmap.smx from your SourceMod plugins directory to the "plugins/disabled" directory
    2. Create a dynamic map rotation and copy it to your game's root directory (the same directory as mapcycle.txt, most likely
    3. Copy dmr.smx to your SourceMod plugins directory
    4. Note: dmr.inc is for plugin authors. You do not need to download dmr.inc for a normal installation.
    Other Cvars
    These cvars are modified and used directly by the plugin and should be considered read only. Modify them at your own peril.
    • dmr_map_key - the current section key in the rotation. DMR will base its nextmap decisions on this section's conditional nextmaps/default_nextmap.
    • dmr_force_nextmap - if sm_setnextmap was used, this cvar stores the value of the nextmap that will be loaded in lieu of the DMR-based nextmap. Setting this value directly will not guarantee it will be used: use sm_setnextmap.
    Compatibility
    This plugin was developed for a TF2 server, but I don't have any reason to believe it would misbehave in other games. Please let me know if it works with other games.

    Version History
    • 2008-03-20 - v0.1
      • Initial release
    • 2008-03-25 - v0.2
      • Fixed bug with Insurgency mod
      • Added GetNextMaps() function for other plugins to retrieve a mapcycle-like list of next maps
    • 2008-04-06 - v0.3
      • Added custom conditions day_eq and day_neq
    • 2008-05-01 - v0.5
      • Added nextmaps command
      • Added sm_nextmap cvar for compatibility with plugins that need to know nextmap info via cvars (ads, etc)
    • 2008-05-06 - v0.6
      • Fixed conditional nextmap bug where times weren't properly calculated when both time_lte and time_gte are used in a single conditional nextmap
      • Added sm_unsetnextmap command
      • Added sm_reloaddmr command
    • 2008-05-14 - v0.7
      • Fixed bug involving time ranges (when both time_lte and time_gte are used in the same conditional nextmap)
    Todo
    • Complete comments
    • Add better support for specifying time ranges that straddle midnight
    • Global conditional nextmaps
    • Verify compatibility with other rotation-related plugins (rtv/votemaps/etc)
    How am I using it? This is my server's rotation as of this writing: http://tf2.2fort2furious.com/images/dmr.php

    I'd love to hear any feedback or suggestions about the plugin.
    Attached Files
    File Type: inc dmr.inc (1.4 KB, 917 views)
    File Type: sp Get Plugin or Get Source (dmr.sp - 2554 views - 23.3 KB)

    Last edited by FLOOR_MASTER; 05-15-2008 at 01:44.
    FLOOR_MASTER is offline
    DontWannaName
    Veteran Member
    Join Date: Jun 2007
    Location: VALVe Land, WA
    Old 03-20-2008 , 22:53   Re: Dynamic Map Rotations
    Reply With Quote #2

    I will try this out. Just what I needed. Have to figure out the txt file a little bit more.
    __________________

    DontWannaName is offline
    FLOOR_MASTER
    Senior Member
    Join Date: Mar 2008
    Old 03-20-2008 , 23:25   Re: Dynamic Map Rotations
    Reply With Quote #3

    One thing I should note is that I don't know if DMR plays nice with rockthevote and similar map-related plugins. I really don't know either way (I haven't looked into it) but I'll be sure to resolve this for the next version. DMR seems to work fine with basevotes/votemap and rockthevote. I don't know enough about mapchooser yet to test it out with mapchooser, but I suspect there will be issues with mapchooser.

    Let me know if you need any help constructing your dmr.txt. I'm on gamesurge as FLOOR_MASTER.

    Last edited by FLOOR_MASTER; 03-21-2008 at 04:11.
    FLOOR_MASTER is offline
    tony2kownz
    Junior Member
    Join Date: Jan 2008
    Old 03-21-2008 , 12:14   Re: Dynamic Map Rotations
    Reply With Quote #4

    looks very interesting, I'll check this out.
    __________________


    tony2kownz is offline
    Caught off Guard
    Senior Member
    Join Date: Jan 2008
    Old 03-24-2008 , 06:52   Re: Dynamic Map Rotations
    Reply With Quote #5

    hi

    im gonna try this on my insurgency server (217.163.31.17:27015). many thanks for the automated generator - it helped me alot for figuring this baby out i'll let you know the outcome. for your reference my following rotation is set to:

    Code:
    "rotation"
    {
     "start" "10"
     "10"
     {
      "map"   "ins_almaden"
      "default_nextmap" "20"
      "30"
             {
                  "players_lte"    "18"
             }
     }
     "20"
     {
      "map"   "ins_ramadi"
      "default_nextmap" "30"
      }
     "30"
     {
      "map"   "ins_baghdad"
      "default_nextmap" "40"
      "50"
             {
                  "players_lte"    "14"
             }
     }
     "40"
     {
      "map"   "ins_haditha"
      "default_nextmap" "50"
     }
     "50"
     {
      "map"   "ins_sinjar"
      "default_nextmap" "60"
      "10"
      {
                 "players_lte"    "18"
             }
     }
     "60"
     {
      "map"   "ins_hillah"
      "default_nextmap" "10"
     }
    }
    If working correctly it should miss out 3 maps if there are unsufficient numbers on the server
    Caught off Guard is offline
    KMFrog
    Senior Member
    Join Date: Oct 2007
    Old 03-24-2008 , 08:00   Re: Dynamic Map Rotations
    Reply With Quote #6

    nice work
    __________________
    Was I helpful or not? Rate Me!
    KMFrog is offline
    Caught off Guard
    Senior Member
    Join Date: Jan 2008
    Old 03-25-2008 , 06:07   Re: Dynamic Map Rotations
    Reply With Quote #7

    hi

    unfortuantely this plugin doesnt seem to be working for insurgency. I used your automated tool to generate the dmr.txt (seen above^^).

    unfortuantely there isnt much in the way of info in the error logs except for:

    Code:
    L 03/23/2008 - 21:49:58: Info (map "ins_almaden") (file "errors_20080323.log")
    L 03/23/2008 - 22:17:04: Info (map "ins_ramadi") (file "errors_20080323.log")
    L 03/23/2008 - 22:37:26: Info (map "ins_baghdad") (file "errors_20080323.log")
    L 03/23/2008 - 23:10:19: Info (map "ins_haditha") (file "errors_20080323.log")
    L 03/23/2008 - 23:33:10: Info (map "ins_sinjar") (file "errors_20080323.log")
    As far as I am aware there wasnt sufficient players on to play some of the maps.

    have i implemented the plugin incorrectly?

    thanks in advance
    Caught off Guard is offline
    FLOOR_MASTER
    Senior Member
    Join Date: Mar 2008
    Old 03-25-2008 , 08:51   Re: Dynamic Map Rotations
    Reply With Quote #8

    Your dmr.txt is perfect, so the error involves some incompatibility between the plugin and Insurgency. I'm downloading the Insurgency client/server now and will try to duplicate the problem.
    FLOOR_MASTER is offline
    Caught off Guard
    Senior Member
    Join Date: Jan 2008
    Old 03-25-2008 , 09:33   Re: Dynamic Map Rotations
    Reply With Quote #9

    Quote:
    Originally Posted by FLOOR_MASTER View Post
    Your dmr.txt is perfect, so the error involves some incompatibility between the plugin and Insurgency. I'm downloading the Insurgency client/server now and will try to duplicate the problem.
    thanks thats very much appreciated.

    just in case its me being thick......i added the cvars (dmr_map_key and dmr_force_nextmap) to the sourcemod.cfg file, exactly how you wrote them above ^^ (e.g. without numbers/values against them). if it was me being thick - apologies

    just so you know it is controlling the map rotation as nextmap.smx is disabled and the maps are rotating just not using the dynamic function that this plugin is made for.

    many thanks in advance for your time
    Caught off Guard is offline
    FLOOR_MASTER
    Senior Member
    Join Date: Mar 2008
    Old 03-25-2008 , 17:15   Re: Dynamic Map Rotations
    Reply With Quote #10

    I've uploaded version 0.2 which should address the bug in Insurgency - I wasn't able to reproduce your specific errors but I did find what I think is the bug that lead to your errors.

    The other thing I noticed was that the in-game "nextmap" command didn't work, and the command didn't work in nextmap.smx either. I've added fixing this on my todo list.

    Please let me know if this version works out for you...
    FLOOR_MASTER 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 03:20.


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