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

Server Restart Modification / Help Requests/ can Authors help?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkwob
BANNED
Join Date: Oct 2018
Old 09-24-2020 , 06:09   Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #1

I want to add adjustable time to this plugin, but I couldn't. I also want to have it write "server shutdown" after the countdown instead of "server disconnected".

sample adjustable time.

!restart 5
after typing, restart the server after 5 seconds.
if you don't write anything and just say !restart let it after 10 seconds when we type restart.


PHP Code:
#pragma semicolon 1
#include <sourcemod>
#pragma newdecls required

int    TimerUpdate;
char   file[PLATFORM_MAX_PATH], id_player[32];
Handle count null;

public 
Plugin myinfo 
{
    
name "[L4D] Team Restarts Server.",
    
author "AlexMy",
    
description "",
    
version "1.1",
    
url "https://forums.alliedmods.net/showthread.php?p=2548680#post2548680"
};

public 
void OnPluginStart()
{
    
LoadTranslations("l4d_restart.phrases");
    
    
count CreateConVar("l4d_restart_time""10""Через сколько секунд сервер перезагрузится"FCVAR_NOTIFY);
    
    
RegAdminCmd("sm_restart"sm_restartADMFLAG_GENERIC);
    
RegAdminCmd("sm_rst",     sm_restartADMFLAG_GENERIC);
}
public 
Action sm_restart(int clientint args)
{
    if(
client)
    {
        
TimerUpdate GetConVarInt(count);
        
CreateTimer(1.0timer_start_TIMER_REPEAT);
        
GetClientName(clientid_playersizeof(id_player));
        
BuildPath(Path_SMfilesizeof(file), "logs/restart_server.log");
        
LogToFileEx(file"Admin %s rebooted the server"id_player);
        
PrintToChat(client"%t""admin_warning"id_player);
    }
    return 
Plugin_Handled;
}
public 
Action timer_start(Handle timer)
{
    
TimerUpdate --;
    if(
TimerUpdate 0)
    {
        
PrintHintTextToAll("%t""countdown_timer"TimerUpdate);
        return 
Plugin_Continue;
    }
    
CreateTimer(0.5restart_server_PrintHintTextToAll("%t""warning_restart"));
    return 
Plugin_Stop;
}
public 
Action restart_server(Handle timer)
{
    
ServerCommand("exit");
    return 
Plugin_Stop;

Darkwob is offline
Quantumss
New Member
Join Date: Sep 2019
Old 09-24-2020 , 08:06   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #2

You can look at this plugin it changes map and reconnect all players

https://github.com/quantum-o/QuickRestart
Quantumss is offline
Darkwob
BANNED
Join Date: Oct 2018
Old 09-24-2020 , 08:53   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #3

Quote:
Originally Posted by Quantumss View Post
You can look at this plugin it changes map and reconnect all players

https://github.com/quantum-o/QuickRestart
bro ekletini denedim ama istediğim gibi bir eklenti değil sen mapı aynı şekilde yeniden oynatıyorsun ben sunucuya restart atmasını istiyorum ayarladığın süre sonra otomatik restart atsın mesela !restart 5 gibi 5 saniye sonra restart atsın sunucuya.Senin eklentin sunucuya restart artmıyor mapı yeniden oynatıyor tüm oyuncuları öldürüp

Last edited by Darkwob; 09-24-2020 at 09:24.
Darkwob is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-24-2020 , 09:16   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #4

Here something. Compile it yourself.

Code:
restartserver.sp // source
translations/restart_server.phrases.txt // default translation file "en"
translations/fi/restart_server.phrases.txt // Finnish translation file "fi"
Edit default "English" translation file how you like it.
To create more translations, make copy of Finnish translation file and edit to else, in own language folder.
- Don't create translation file from default file!


*edit
Ou yeah, sm_restart is default 10 seconds.
1 sec is minimi, 120 sec is max. Only players can use, not from server console.
Attached Files
File Type: zip restartserver.zip (1.9 KB, 70 views)
__________________
Do not Private Message @me

Last edited by Bacardi; 09-24-2020 at 09:20. Reason: my windows didn't delete extra files...
Bacardi is offline
freak.exe_uLow
AlliedModders Donor
Join Date: Jul 2012
Location: Germany
Old 09-24-2020 , 12:51   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
Here something. Compile it yourself.

Code:
restartserver.sp // source
translations/restart_server.phrases.txt // default translation file "en"
translations/fi/restart_server.phrases.txt // Finnish translation file "fi"
Edit default "English" translation file how you like it.
To create more translations, make copy of Finnish translation file and edit to else, in own language folder.
- Don't create translation file from default file!


*edit
Ou yeah, sm_restart is default 10 seconds.
1 sec is minimi, 120 sec is max. Only players can use, not from server console.
Hey Bacardi, do you have that with only messages? I'm looking for a Restart Message Plugin that only writes the messages in the chat, the restart is done by my webpanel (maybe even that the people automatically get a rejoin) ^^
freak.exe_uLow is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-24-2020 , 14:56   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #6

...you can remove "ServerCommand" part
and edit "PrintHintTextToAll" to "PrintToChatAll"
__________________
Do not Private Message @me
Bacardi is offline
freak.exe_uLow
AlliedModders Donor
Join Date: Jul 2012
Location: Germany
Old 09-24-2020 , 15:41   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
...you can remove "ServerCommand" part
and edit "PrintHintTextToAll" to "PrintToChatAll"
Your script is structured a little bit different..Would you mind if you could create something like this? With messages from 5,4,3,2,1,30sec, 15sec,10sec 5sec,4sec,3sec,2sec,1sec and Server restart now!!! and a retry function at the end? I have been looking for something like this before, but all plugins have a shutdown in them, just need the messages to let the players know

Info: i have the restart at 5 am (live in germany) maybe it is possible that he also takes the time

Last edited by freak.exe_uLow; 09-24-2020 at 15:48.
freak.exe_uLow is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-25-2020 , 16:43   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #8

Quote:
Originally Posted by freak.exe_uLow View Post
Your script is structured a little bit different..Would you mind if you could create something like this? With messages from 5,4,3,2,1,30sec, 15sec,10sec 5sec,4sec,3sec,2sec,1sec and Server restart now!!! and a retry function at the end? I have been looking for something like this before, but all plugins have a shutdown in them, just need the messages to let the players know

Info: i have the restart at 5 am (live in germany) maybe it is possible that he also takes the time
I'm not 100% sure what you request...
Also I was playing with SQLite, with this you can get UNIX timestamp to specific time of the (any) day.

old


updated
PHP Code:
#include <sdktools>

Database MyDataBase;

int timestamp;

public 
void OnPluginStart()
{
    
AddCommandListener(listencmd"timeleft");

    
Start();
}

void Start()
{

    if(
MyDataBase == null)
        
MyDataBase SQLite_UseDatabase("storage-local"""0);

    
// Get UNIXTIME, compensate with local time, today's 5:00
    
DBResultSet query SQL_Query(MyDataBase"SELECT strftime('%s','now','start of day','+5 hours','-1 seconds','utc')");
    
timestamp SQL_FetchInt(query0);

    

    if( (
timestamp GetTime()) < )
    {
        
delete query;

        
query SQL_Query(MyDataBase"SELECT strftime('%s','now','start of day','+1 day','+5 hours','-1 seconds','utc')");
        
timestamp SQL_FetchInt(query0);
    }

    
//PrintToServer("seconds %i", timestamp - GetTime());

    
CreateTimer(1.0MyTimer_TIMER_REPEAT);
    
    
delete query;
    
delete MyDataBase;
}

public 
Action listencmd(int client, const char[] commandint argc)
{
    
int timeleft timestamp GetTime();

    
char buffer[60];
    
FormatTime(buffersizeof(buffer), NULL_STRINGtimestamp);

    
ReplyToCommand(client"[SM] Restart server in \
                            %02iHours %02iMinutes %02iSeconds\
                            \nDatetime = %s"
,
                            
timeleft 3600 24timeleft 60 60timeleft 60,
                            
buffer);

    return 
Plugin_Continue;
}


public 
Action MyTimer(Handle timer)
{

    
int timeleft timestamp GetTime();
    
//PrintToServer("seconds %i", timeleft);

    
switch(timeleft)
    {
        case 
900:
        {
            
PrintToChatAll("[SM] Server restart in %i minutes"timeleft 60);
        }

        case 
600:
        {
            
PrintToChatAll("[SM] Server restart in %i minutes"timeleft 60);
        }
        case 
10:
        {
            
PrintToChatAll("[SM] Server restart in %i seconds"timeleft);
        }
        case 
5,4,3,2,1:
        {
            
PrintToChatAll("%i"timeleft);
        }
        case 
0:
        {
            
PrintToChatAll("[SM] Server restart Now!");
        }
    }

    if(
timeleft <= 0)
    {
        
Start();


        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsClientInGame(i) || IsFakeClient(i)) continue;
            
            
ReconnectClient(i);
        }

        return 
Plugin_Stop
    
}

    return 
Plugin_Continue;

__________________
Do not Private Message @me

Last edited by Bacardi; 09-26-2020 at 04:44. Reason: prevent duplicated addcommandlisteners
Bacardi is offline
freak.exe_uLow
AlliedModders Donor
Join Date: Jul 2012
Location: Germany
Old 09-25-2020 , 17:44   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
I'm not 100% sure what you request...
Also I was playing with SQLite, with this you can get UNIX timestamp to specific time of the (any) day.

So, this version (should) start countdown before time hit 5:00
PHP Code:

Database MyDataBase
;

public 
void OnPluginStart()
{
    if(
MyDataBase == null)
        
MyDataBase SQLite_UseDatabase("storage-local"""0);

    
// Get UNIXTIME, compensate with local time, today's 5:00 - current time
    
DBResultSet query SQL_Query(MyDataBase"SELECT strftime('%s','now','start of day','+1 day','+5 hours','-5 seconds','utc')");
    
int seconds SQL_FetchInt(query0);

    if( (
seconds GetTime()) < )
    {
        
delete query;

        
query SQL_Query(MyDataBase"SELECT strftime('%s','now','start of day','+2 day','+5 hours','-5 seconds','utc')");
        
seconds SQL_FetchInt(query0);
    }

    
CreateTimer(1.0MyTimersecondsTIMER_REPEAT);
    
    
delete query;
    
delete MyDataBase;
}


public 
Action MyTimer(Handle timerint seconds)
{

    
int timeleft seconds GetTime();

    switch(
timeleft)
    {
        case 
31:
        {
            
PrintToChatAll("Server restart - Countdown begin...");
        }

        case 
30:
        {
            
PrintToChatAll("30 seconds");
        }

        case 
15:
        {
            
PrintToChatAll("15 seconds");
        }
        case 
10:
        {
            
PrintToChatAll("10 seconds");
        }
        case 
9,8,7,6,5,4,3,2:
        {
            
PrintToChatAll("%i seconds"timeleft);
        }
        case 
1:
        {
            
PrintToChatAll("Server restart now!!!");
        }
    }

    if(
timeleft <= 0)
    {
        
OnPluginStart();
        return 
Plugin_Stop
    
}

    return 
Plugin_Continue;

Thank you first, and I let my webpanel with which I run my servers do the restart at 5am. Now i wanted to have a manual plugin which shows the restart in the chat, the first message should be at 04:45 am with server restart in 15min then 10 min then 10 min then 5,4,3,2,1 and at the end shortly before the restart he should show the message Server restart Now
freak.exe_uLow is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-26-2020 , 04:38   Re: Server Restart Modification / Help Requests/ can Authors help?
Reply With Quote #10

ok, I updated my previous post
#8

- You can check timestamp when server suppose to "restart" with console command: timeleft
Code:
[SM] Restart server in 17Hours 21Minutes 41Seconds
Datetime = 09/27/2020 - 04:59:59
- There is now also Reconnect players at end. Remove that if gives trouble.
- To adjust time, try give more seconds in Query string.
Code:
"SELECT strftime('%s','now','start of day','+5 hours','-1 seconds','utc')");
to
"SELECT strftime('%s','now','start of day','+5 hours','-3 seconds','utc')");
so on...
__________________
Do not Private Message @me

Last edited by Bacardi; 09-26-2020 at 04:38.
Bacardi 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 12:59.


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