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

Daily restart plugin


Post New Thread Reply   
 
Thread Tools Display Modes
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
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-09-2021 , 11:48   Re: Daily restart plugin
Reply With Quote #2

Here's a plugin i had before, i added just one simple line which should do the trick for you.

Since this is the "Scripting Help" section, you'll be able to edit the plugin to your likings (with or without hudmessage etc.), if not, make a new thread in suggestions/requests.

PHP Code:
/* Sublime AMXX Editor v2.2 */

#pragma semicolon 1

#include <amxmodx>

#define PLUGIN  "Show Players"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#define MSGID 81045

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

enum _:ePlayerInfo
{
    
iTotalPlayers,
    
iCtPlayers,
    
iCtAlive,
    
iTerPlayers,
    
iTerAlive
};

new 
iInfo[ePlayerInfo];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
client_putinserver(id)
{
    
iInfo[iTotalPlayers]++;

    if(!
task_exists(MSGID))
    {
        
set_task(10.0"displayMessage"MSGID);
    }
}


#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    
iInfo[iTotalPlayers]--;

    if(
iInfo[iTotalPlayers] == 0)
    {
        
remove_task(MSGID);
        
server_cmd("sv_restart 1");
    }
}

public 
displayMessage()
{
    if(
task_exists(MSGID))
    {
        new 
iPlayers[MAX_PLAYERS], iNum;

        
get_players(iPlayersiNum"e""TERRORIST");
        
iInfo[iTerPlayers] = iNum;

        
get_players(iPlayersiNum"ae""TERRORIST");
        
iInfo[iTerAlive] = iNum;

        
get_players(iPlayersiNum"e""CT");
        
iInfo[iCtPlayers] = iNum;

        
get_players(iPlayersiNum"ae""CT");
        
iInfo[iCtAlive] = iNum;

        
get_players(iPlayersiNum);

        for(new 
iiNumi++)
        {
            
set_hudmessage(random(255), random(255), random(255), -1.00.000.01.10.10.2, -1);
            
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              
iInfo[iTerAlive], iInfo[iTerPlayers],
                              
iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        
set_task(1.0"displayMessage"MSGID);
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
feren02
Senior Member
Join Date: Mar 2012
Old 01-10-2021 , 11:09   Re: Daily restart plugin
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Here's a plugin i had before, i added just one simple line which should do the trick for you.

Since this is the "Scripting Help" section, you'll be able to edit the plugin to your likings (with or without hudmessage etc.), if not, make a new thread in suggestions/requests.

PHP Code:
/* Sublime AMXX Editor v2.2 */

#pragma semicolon 1

#include <amxmodx>

#define PLUGIN  "Show Players"
#define VERSION "1.0"
#define AUTHOR  "NapoleoN#"

#define MSGID 81045

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32;
#endif

enum _:ePlayerInfo
{
    
iTotalPlayers,
    
iCtPlayers,
    
iCtAlive,
    
iTerPlayers,
    
iTerAlive
};

new 
iInfo[ePlayerInfo];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
client_putinserver(id)
{
    
iInfo[iTotalPlayers]++;

    if(!
task_exists(MSGID))
    {
        
set_task(10.0"displayMessage"MSGID);
    }
}


#if AMXX_VERSION_NUM < 183
public client_disconnect(id)
#else
public client_disconnected(id)
#endif
{
    
iInfo[iTotalPlayers]--;

    if(
iInfo[iTotalPlayers] == 0)
    {
        
remove_task(MSGID);
        
server_cmd("sv_restart 1");
    }
}

public 
displayMessage()
{
    if(
task_exists(MSGID))
    {
        new 
iPlayers[MAX_PLAYERS], iNum;

        
get_players(iPlayersiNum"e""TERRORIST");
        
iInfo[iTerPlayers] = iNum;

        
get_players(iPlayersiNum"ae""TERRORIST");
        
iInfo[iTerAlive] = iNum;

        
get_players(iPlayersiNum"e""CT");
        
iInfo[iCtPlayers] = iNum;

        
get_players(iPlayersiNum"ae""CT");
        
iInfo[iCtAlive] = iNum;

        
get_players(iPlayersiNum);

        for(new 
iiNumi++)
        {
            
set_hudmessage(random(255), random(255), random(255), -1.00.000.01.10.10.2, -1);
            
show_hudmessage(iPlayers[i], "Terrorists: %i/%i | Counter-Terrorists: %i/%i",
                              
iInfo[iTerAlive], iInfo[iTerPlayers],
                              
iInfo[iCtAlive], iInfo[iCtPlayers]);
        }
        
set_task(1.0"displayMessage"MSGID);
    }

Shocks dude, was able to apply it to server. Very basic but works like a charm! Thank you so much for you man! <3
feren02 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 02:30.


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