Raised This Month: $ Target: $400
 0% 

Daily restart plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
feren02
Senior Member
Join Date: Mar 2012
Old 01-08-2021 , 21:40   Daily restart plugin
Reply With Quote #1

Hello everyone! Hope you are somehow fine during this pandemic.

Anyway, would like to seek help for a simple plugin that triggers server restart when it detects that there are no players / zero players in server. Hope it does not spam restart whenever server has zero players.

I am using this plugin, but it seems like it does not work and nothing happens:

PHP Code:
#include <amxmodx>

public plugin_init() 
    
register_plugin("restart","1.2","watch")


public 
check_restart()
{
    new 
currentdate[12], lastrestarted[12]
    
get_time("%d/%m/%Y",currentdate,11)

    if (!
vaultdata_exists("lastrestarted")) 
        
set_vaultdata("lastrestarted",currentdate)

    
get_vaultdata("lastrestarted",lastrestarted,11)
    
    if (!
equal(currentdate,lastrestarted)) 
    {
        new 
i,playercount,botcount
        playercount 
get_playersnum()

        for(
i=1i<= playercounti++)
            if(
is_user_bot(i) || is_user_hltv(i))
                
botcount++
            
        if (
playercount == botcount
        {
            
set_vaultdata("lastrestarted",currentdate)
            
log_amx("Restarting: (Last Restart: %s) (Clients: %d) (Bots: %d)",lastrestartedplayercount-botcountbotcount)
            
server_cmd("exit"
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
client_disconnect()
{
    
set_task(1.0,"check_restart")
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2057\\ f0\\ fs16 \n\\ par }
*/ 

Looking forward!
feren02 is offline
 



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 14:11.


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