Raised This Month: $32 Target: $400
 8% 

[TF2/ANY?] Auto map reload (v1.1, 20/10/2017)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
91346706501435897134
Member
Join Date: Oct 2017
Plugin ID:
5866
Plugin Version:
v1.1
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Automatically reloads the current map every 12 hours to avoid server lag.
    Old 10-17-2017 , 19:21   [TF2/ANY?] Auto map reload (v1.1, 20/10/2017)
    Reply With Quote #1

    Description
    Automatically reloads the current map every 12 hours to avoid server lag.

    ConVars
    Code:
    // timer in seconds (WARNING: RELOAD MAP FOR CHANGES TO TAKE EFFECT)
    // -
    // Default: "43200.000000"
    // Minimum: "3600.000000"
    // Maximum: "86400.000000"
    sm_auto_map_reload_time "43200.000000"
    Changelog
    Quote:
    20/10/2017 (v1.1)

    * Added ConVar sm_auto_map_reload_time <time in seconds>
    * Plugin now notifys every player when timer hits 60 seconds.

    18/10/2017 (v1.0)

    * Initial release.
    Installation instructions
    place auto_map_restart.smx in your addons/sourcemod/plugins folder and then reload your server map.

    Plans
    - Add more customization
    Attached Files
    File Type: sp Get Plugin or Get Source (auto_map_reload.sp - 647 views - 1.0 KB)

    Last edited by 91346706501435897134; 10-20-2017 at 10:28.
    91346706501435897134 is offline
    ThatKidWhoGames
    Veteran Member
    Join Date: Jun 2013
    Location: IsValidClient()
    Old 10-19-2017 , 11:59   Re: [TF2/ANY?] Auto map reload (v1.0, 18/10/2017)
    Reply With Quote #2

    Nice release! Though, I would try to add something that differentiates this from this plugin https://forums.alliedmods.net/showth...41399?t=141399
    ThatKidWhoGames is offline
    91346706501435897134
    Member
    Join Date: Oct 2017
    Old 10-20-2017 , 10:30   update 1.1
    Reply With Quote #3

    update 1.1
    Quote:
    20/10/2017 (v1.1)

    * Added ConVar sm_auto_map_reload_time <time in seconds>
    * Plugin now notifys every player when timer hits 60 seconds.
    91346706501435897134 is offline
    ThatKidWhoGames
    Veteran Member
    Join Date: Jun 2013
    Location: IsValidClient()
    Old 10-20-2017 , 11:32   Re: [TF2/ANY?] Auto map reload (v1.1, 20/10/2017)
    Reply With Quote #4

    Cleaned up the code a bit. Also, added cvar change hook and made it execute OnMapStart when the plugin is reloaded so no map change is necessary to change the timer value.
    PHP Code:
    #include <sourcemod>

    public Plugin myinfo =
    {
        
    name "auto_map_reload",
        
    author "91346706501435897134",
        
    description "automatically reloads the current map",
        
    version "1.1",
    };

    ConVar sm_auto_map_reload_time;
    float fTime;

    public 
    void OnPluginStart()
    {
        
    sm_auto_map_reload_time CreateConVar("sm_auto_map_reload_time""43200.0""Timer in seconds (WARNING: RELOAD MAP FOR CHANGES TO TAKE EFFECT)"FCVAR_NOTIFYtrue3600.0true86400.0);
        
    fTime sm_auto_map_reload_time.FloatValue;
        
        
    sm_auto_map_reload_time.AddChangeHook(CvarUpdate);
        
        
    AutoExecConfig(true);
        
        
    OnMapStart();
    }

    public 
    void CvarUpdate(ConVar cvar, const char[] oldValue, const char[] newValue)
    {
        
    fTime sm_auto_map_reload_time.FloatValue;
    }

    public 
    void OnMapStart()
    {
        
    CreateTimer(fTime-60.0notify_map_reload);
    }

    public 
    Action notify_map_reload(Handle timer)
    {
        
    PrintHintTextToAll(">> Map reloading in 60 seconds <<");
        
    CreateTimer(60.0map_reload);
    }

    public 
    Action map_reload(Handle timer)
    {
        
    char current_map_name[255];
        
    GetCurrentMap(current_map_namesizeof(current_map_name));
        
    ServerCommand("changelevel %s"current_map_name);    

    ThatKidWhoGames is offline
    91346706501435897134
    Member
    Join Date: Oct 2017
    Old 10-20-2017 , 11:38   Re: [TF2/ANY?] Auto map reload (v1.1, 20/10/2017)
    Reply With Quote #5

    Quote:
    Originally Posted by ThatKidWhoGames View Post
    Cleaned up the code a bit. Also, added cvar change hook and made it execute OnMapStart when the plugin is reloaded so no map change is necessary to change the timer value.
    PHP Code:
    #include <sourcemod>

    public Plugin myinfo =
    {
        
    name "auto_map_reload",
        
    author "91346706501435897134",
        
    description "automatically reloads the current map",
        
    version "1.1",
    };

    ConVar sm_auto_map_reload_time;
    float fTime;

    public 
    void OnPluginStart()
    {
        
    sm_auto_map_reload_time CreateConVar("sm_auto_map_reload_time""43200.0""Timer in seconds (WARNING: RELOAD MAP FOR CHANGES TO TAKE EFFECT)"FCVAR_NOTIFYtrue3600.0true86400.0);
        
    fTime sm_auto_map_reload_time.FloatValue;
        
        
    sm_auto_map_reload_time.AddChangeHook(CvarUpdate);
        
        
    AutoExecConfig(true);
        
        
    OnMapStart();
    }

    public 
    void CvarUpdate(ConVar cvar, const char[] oldValue, const char[] newValue)
    {
        
    fTime sm_auto_map_reload_time.FloatValue;
    }

    public 
    void OnMapStart()
    {
        
    CreateTimer(fTime-60.0notify_map_reload);
    }

    public 
    Action notify_map_reload(Handle timer)
    {
        
    PrintHintTextToAll(">> Map reloading in 60 seconds <<");
        
    CreateTimer(60.0map_reload);
    }

    public 
    Action map_reload(Handle timer)
    {
        
    char current_map_name[255];
        
    GetCurrentMap(current_map_namesizeof(current_map_name));
        
    ServerCommand("changelevel %s"current_map_name);    

    Thanks alot, I will soon update the plugin with the cleaned up code :)
    91346706501435897134 is offline
    ThatKidWhoGames
    Veteran Member
    Join Date: Jun 2013
    Location: IsValidClient()
    Old 10-20-2017 , 12:06   Re: [TF2/ANY?] Auto map reload (v1.1, 20/10/2017)
    Reply With Quote #6

    Quote:
    Originally Posted by 91346706501435897134 View Post
    Thanks alot, I will soon update the plugin with the cleaned up code
    No worries!
    ThatKidWhoGames 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 23:59.


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