Raised This Month: $ Target: $400
 0% 

Force Server Restart


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 09-07-2009 , 01:44   Force Server Restart
Reply With Quote #1

Would there be a way to make a plugin that forces server restart "rcon restart" or "rcon quit" when there is only X amount of people in the server between 4am-10am.

Also what are the scripting commands for the admin flags?

; m - custom level A (for additional plugins)
; n - custom level B
; o - custom level C
; p - custom level D
; q - custom level E
; r - custom level F
; s - custom level G
; t - custom level H

like j is AMX_VOTE
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 09-07-2009 , 02:11   Re: Force Server Restart
Reply With Quote #2

Code:
#define ADMIN_LEVEL_A        (1<<12)    /* flag "m" */
#define ADMIN_LEVEL_B        (1<<13)    /* flag "n" */
#define ADMIN_LEVEL_C        (1<<14)    /* flag "o" */
#define ADMIN_LEVEL_D        (1<<15)    /* flag "p" */
#define ADMIN_LEVEL_E        (1<<16)    /* flag "q" */
#define ADMIN_LEVEL_F        (1<<17)    /* flag "r" */
#define ADMIN_LEVEL_G        (1<<18)    /* flag "s" */
#define ADMIN_LEVEL_H        (1<<19)    /* flag "t" */
About the plugin you requested; yes, that is possible. I'm sure that someone will help you out with that in no time since that's quite easy.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-07-2009 , 18:45   Re: Force Server Restart
Reply With Quote #3

Quote:
Originally Posted by DarkGod View Post
I'm sure that someone will help you out with that in no time since that's quite easy.
This is "Scripting Help" so we should only help him if he already has code to work with.

Of course, that's only my opinion .
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-07-2009 , 19:24   Re: Force Server Restart
Reply With Quote #4

Code:
#include < amxmodx > #include < amxmisc > const MIN_PLAYERS = 4; new bool:g_bEnabled; new g_iPlayerCount; new bool:g_bFinishedFirstCheck; new bool:g_bRestarting; public plugin_init( ) {     new iCurrentTime = get_systime( );         new iLastTime = get_vaultdata( "last_restart" );         if( ( iCurrentTime - iLastTime ) >= ( 6 * 60 * 60 ) ) // 6 * 60 * 60 = 6 hours in seconds = 4 am -> 10 am     {         g_bEnabled = true;         set_task( 120.0, "TaskFirstCheck" );     } } public client_putinserver( client ) {     if( !is_user_bot( client ) )     {         g_iPlayerCount++;     } } public client_disconnect( client ) {     if( !is_user_bot( client ) )     {         g_iPlayerCount--;                 if( g_bFinishedFirstCheck )         {             Check( );         }     } } public TaskFirstCheck( ) {     g_bFinishedFirstCheck = true;         Check( ); } Check( ) {     if( g_bEnabled && g_iPlayerCount <= MIN_PLAYERS && !g_bRestarting )     {         static szTime[ 3 ];         format_time( szTime, 2, "%H" );                 if( 4 <= str_to_num( szTime ) <= 10 )         {             client_print( 0, print_chat, "Server is restarting due to low amount of players." );                         static szSysTime[ 16 ];             num_to_str( get_systime( ), szSysTime, 15 );             set_vaultdata( "last_restart", szSysTime );                         g_bRestarting = true;             set_task( 5.0, "TaskRestart" );         }     } } public TaskRestart( ) {     server_cmd( "restart" ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 09-10-2009 at 11:31.
Exolent[jNr] is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 09-07-2009 , 19:52   Re: Force Server Restart
Reply With Quote #5

Hurray I love you guys Well one thing that just came to mind, if this script restarted the server @ 6am and at 9am there are X amount of players still would it just restart it again or over and over till 10am?

Just a question, this means that it wont restart if its happened in the last 120 minutes?
{
set_task( 120.0, "TaskFirstCheck" );
}
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.

Last edited by Kitami; 09-07-2009 at 19:55.
Kitami is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-07-2009 , 19:59   Re: Force Server Restart
Reply With Quote #6

No. That gives the plugin a 2 minute delay for players to connect to make sure that there are no mistakes upon map changes.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 09-07-2009 , 21:51   Re: Force Server Restart
Reply With Quote #7

So then it should restart 60 times in 5 hours if theirs no one on the server between 4-10am? Also im guessing it does count bots as they are not clients?
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 09-08-2009 , 08:24   Re: Force Server Restart
Reply With Quote #8

know it counts only real player
PHP Code:
#include < amxmodx >
#include < amxmisc >

const MIN_PLAYERS 4;

new 
g_iPlayerCount;
new 
bool:g_bFinishedFirstCheck;
new 
bool:g_bRestarting;

public 
plugin_init( )
{
    
set_task120.0"TaskFirstCheck" );
}

public 
client_putinserverclient )
{
    if( !
is_user_botclient ) )
        
g_iPlayerCount++;
}

public 
client_disconnectclient )
{
    if( !
is_user_botclient ) )
        
g_iPlayerCount--;
    
    if( 
g_bFinishedFirstCheck )
    {
        
Check( );
    }
}

public 
TaskFirstCheck( )
{
    
g_bFinishedFirstCheck true;
    
    
Check( );
}

Check( ) 
{
    if( 
g_iPlayerCount <= MIN_PLAYERS && !g_bRestarting )
    {
        static 
szTime];
        
format_timeszTime2"%H" );
        
        if( 
<= str_to_numszTime ) <= 10 )
        {
            
client_print0print_chat"Server is restarting due to low amount of players." );
            
            
g_bRestarting true;
            
set_task5.0"TaskRestart" );
        }
    }
}

public 
TaskRestart( )
{
    
server_cmd"restart" );

__________________
vato loco [GE-S] is offline
deadman909
Veteran Member
Join Date: Oct 2008
Old 09-08-2009 , 21:23   Re: Force Server Restart
Reply With Quote #9

So if theres Less than 4 Players in the Server does the Server Keep Restarting and Restarting?
__________________

deadman909 is offline
Send a message via MSN to deadman909 Send a message via Yahoo to deadman909
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-08-2009 , 21:24   Re: Force Server Restart
Reply With Quote #10

Yes.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 08:04.


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