Raised This Month: $23 Target: $400
 5% 

AutoChangeMap 1.1


Post New Thread Reply   
 
Thread Tools Display Modes
Author
bazo0ka
Junior Member
Join Date: Mar 2006
Plugin ID:
246
Plugin Version:
1.1
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    31 
    Plugin Description:
    Changes the map if 'x' or fewer players are on the server after 'y' consecutive minutes, as defined by the server operator.
    Unapprover:
    Reason for Unapproving:
    Plugin uses same filename as one of Sourcemod base plugins.
    Old 01-05-2008 , 05:54   AutoChangeMap 1.1
    Reply With Quote #1

    Updated 2/25/08 -- Highly recommended to upgrade to new version as it fixes a memory leak!

    Dependencies

    Optional -- nextmap.smx (required for autochangemap_mode 1). Also optional -- modified mapchooser.smx (required if you use both autochangemap_mode 1 and mapchooser.smx at the same time -- explanation below).


    Description

    This plugin causes the map to automatically change when there isn't a certain amount of players on the server for a set amount of time. For example, if you want to have the server change maps when the server is empty for ten minutes, this plugin can accomplish that.

    An alternative function of this plugin would be to always force automatic map changes, regardless of the player count, after a set amount of minutes. This would be useful in games where the last round has to be played out to completion past the map's time limit -- if you do not enjoy that feature. I did not make the plugin with this in mind, so it's implementation may not be ideal for that use.

    This is based on Nicolous' AutoChangeLevel plugin (abandoned). Some code was also taken from SourceMod's nextmap.smx plugin.


    CVars

    autochangemap_client_limit "1"
    // Number of clients that must be connected before automatic map changes are disabled. Zero disables automatic map changes.
    // Default: "1"
    // Minimum: "0.000000"

    autochangemap_include_bots "0"
    // Include bots in the client count (remember, SourceTV counts as a bot).
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "1.000000"

    autochangemap_time_limit "10"
    // Consecutive minutes which must pass while the client limit has not been reached for the automatic map change to occur. Zero disables automatic map changes.
    // Default: "10"
    // Minimum: "0.000000"

    autochangemap_mode "0"
    // Method of choosing the next map in automatic map changes: 0 = custom mapcycle (create new section in sourcemod/configs/maplists.cfg), 1 = sm_nextmap/mapcycle (requires nextmap.smx), 2 = load map in autochangemap_default_map cvar, 3 = reload current map.
    // Default: "0"
    // Minimum: "0.000000"
    // Maximum: "3.000000"

    autochangemap_default_map ""
    // Map to load at automatic map changes when autochangemap_mode is set to '2.'
    // Default: ""

    autochangemap_config_to_exec ""
    // Config to exec when an automatic map change occurs, if desired. Executes after the map loads and server.cfg and SourceMod plugin configs are exec'd.
    // Default: ""


    Installation

    1. Delete old autochangemap.cfg in cfg\sourcemod\ (if applicable).
    2. Configure and add autochangemap.cfg to cfg\sourcemod\.
    3. Add autochangemap.smx to addons\sourcemod\plugins\.
    4. (Optional) Add nextmap.smx to addons\sourcemod\plugins\.
    5. (Optional) Add modified mapchooser.smx to addons\sourcemod\plugins\.

    Nextmap.smx is required if you want to use autochangemap_mode 1. If you use autochangemap_mode 1 and you don't have nextmap.smx, you will get errors.

    The modified mapchooser.smx is required if you want to use autochangemap_mode 1 and MapChooser at the same time. This simply removes the one line in MapChooser that sets sm_nextmap to "Pending Vote." Side effect is that typing "nextmap" in chat will still show the next map in the mapcycle, even if MapChooser is set to run a vote to select the next map. But it's the best I could do for now. The version of MapChooser it's based on is 1895 (2008-02-22). I'll continue to update it as new MapChoosers come out, until I get a better solution or the new map management SourceMod plugin comes out, at which point this plugin will become irrelevant (yay!).


    Configuration

    Autochangemap_mode explanation:

    Automapchange_mode 0 will simply cycle through a custom mapcycle (specified in maplists.cfg -- see instructions below). It doesn't keep track of maps played -- it will just go to the next map in the file any time an automatic map change occurs. Very simple.

    Mode 1 will cycle through your normal map cycle using sm_nextmap, which may be more or less desirable, depending on your needs.

    Mode 2 will load whatever map is specified in autochangemap_default_map.

    Mode 3 will reload the current map.


    Instructions for setting up mapcycle file for autochangemap_mode 0:

    1. Create a maplist file. One map per line, no special syntax. Txt, cfg, ini, whatever. Place it somewhere within the mod folder or subfolders.

    2. Add a "autochangemap" sub-section to addons/sourcemod/configs/maplists.cfg within the "MapLists" section --

    Code:
    "autochangemap"
    {
    	"file"		"<relative path to mapcycle file from mod folder>"
    }

    Important additional notes:

    You can specify a config file to run on automatic map changes with autochangemap_config_to_exec. It runs after loading the new map and after the server.cfg and plugin configs are exec'd. It will only run on map changes triggered by this plugin (automatic map changes).

    IMPORTANT -- set up your autochangemap.cfg file! The config is re-executed on every map change, so if you want your settings to stick, you have to change them in the config file. This has special implications when using autochangemap_config_to_exec -- if you don't specify this in the config file, it will never run!

    Use only integers for numerical type cvars. I didn't code for handling of floating point numbers. (Is there an easy way to force the type for cvars?)


    Change Log

    1.1
    % Substantial rewrite.
    % Added exec'ing a config on automatic map changes.
    % Added cycling through a custom mapcycle file with autochangelevel_mode 0.
    % Added a chat message and a five second delay before changing maps.
    % Added optional custom mapchooser.smx for compatibility with autochangemap_mode 1.
    % Changed autochangemap_type to autochangemap_mode and changed values correlating with modes.
    % Changed default cvar values.
    % Changed/removed some code for dealing with invalid map names. Now the plugin will simply reload the current map if it encounters an invalid map name on trying to change maps.
    % Fixed a memory leak.

    1.0
    % Initial release.


    Please inform me of any bugs/problems.

    Here ya go.
    Attached Files
    File Type: sp Get Plugin or Get Source (autochangemap.sp - 5846 views - 6.4 KB)
    File Type: cfg autochangemap.cfg (1.5 KB, 3001 views)

    Last edited by psychonic; 02-20-2010 at 10:37. Reason: attached mapchooser doesn't comply with forum rules
    bazo0ka is offline
    Extreme_One
    Veteran Member
    Join Date: Nov 2006
    Old 01-05-2008 , 09:05   Re: AutoChangeMap
    Reply With Quote #2

    Works perfectly.

    Good job. Thank you.
    __________________
    Extreme_One is offline
    ratty
    SourceMod Donor
    Join Date: Jan 2006
    Old 01-05-2008 , 14:02   Re: AutoChangeMap
    Reply With Quote #3

    This has a really neat use if you do tv_autorecord with TF2.
    I have it cycle every 5 minutes when nobody is on, then the .dem files are very small, and I have a shell script in linux that just deletes any that are under a certain size, so I can automatically delete demos of when nobody is on.
    Also, when the server empties out each day, that demo will neatly close out within 5 minutes. Kind of a cheesy hack, but works great.
    ratty is offline
    ottobohn
    Senior Member
    Join Date: Sep 2007
    Old 01-06-2008 , 06:10   Re: AutoChangeMap
    Reply With Quote #4

    Awesome! Thank u!

    otto
    ottobohn is offline
    Munra
    Senior Member
    Join Date: May 2004
    Old 01-16-2008 , 17:58   Re: AutoChangeMap
    Reply With Quote #5

    Is there a way around using sm_nextmap? Maybe to be able to make a file(automaplist.txt or somthing) and once there is no one on the server it will just go down the list in the file no matter what the sm_nextmap is set to?

    The reason is I use Rock the vote and end of map voting

    so "sm_nextmap" = "Pending Vote"


    Any Ideas?
    __________________
    http://anbservers.net
    My Plugins
    PMs for support will be ignored please use the plugin topic for support.
    Munra is offline
    bazo0ka
    Junior Member
    Join Date: Mar 2006
    Old 01-19-2008 , 06:23   Re: AutoChangeMap
    Reply With Quote #6

    Hmm. I will take a look at that soon. Honestly, I used sm_nextmap because it was a waaay easy alternative to writing (good) mapcycle management code. Or at least it seems so to me. I am something of a newbie.
    bazo0ka is offline
    ToMee
    Junior Member
    Join Date: Feb 2008
    Old 02-04-2008 , 05:48   Re: AutoChangeMap
    Reply With Quote #7

    Hi bazo0ka!

    I use your plugin and it is very cool!
    It is possible to integrate a function?
    It would be nice that the plugin could exec a config file before changing the map.
    For example: we play a war on the server (has password) and then everybody leaves... after 15 mins with no player the plugin exec a config which has lines like: sv_password "" or change the hostname or something else
    If it's not hard and you have time to code that I would be grateful!

    PS: sry for my english
    ToMee is offline
    417
    Junior Member
    Join Date: Feb 2005
    Location: Midwest, USA
    Old 02-13-2008 , 20:32   Re: AutoChangeMap
    Reply With Quote #8

    Thanks for making a great little plug-in!

    Can you please built into your next version the ability to use a "automaplist.txt" to cycle through a small list of maps using your plug-in.

    If not maybe build in the ability to add 3-5 maps in the CVAR: autochangemap_default_map "map_name. I.E. autochangemap_default_map"ctf_2fort, ff_dev2fort, ff_dm3, dm_island17, dm_sexualchocolate"
    __________________
    [SG-X] Loki
    SG-X Clan
    417 is offline
    Send a message via ICQ to 417
    Kramerika
    Senior Member
    Join Date: Dec 2004
    Location: PA, US of A
    Old 02-14-2008 , 08:32   Re: AutoChangeMap
    Reply With Quote #9

    Quote:
    Originally Posted by 417 View Post
    Can you please built into your next version the ability to use a "automaplist.txt" to cycle through a small list of maps using your plug-in.
    I second this! It would give us more flexibility which is always a good thing.
    Kramerika is offline
    bazo0ka
    Junior Member
    Join Date: Mar 2006
    Old 02-16-2008 , 20:14   Re: AutoChangeMap
    Reply With Quote #10

    Yes, I will do that. Sorry for the lack of updates. I'm just a bit slow when it comes to coding.
    bazo0ka 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 04:19.


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