Sign in to follow this  
Vadi

RESTART SCRIPT by Weeks [15thMEU(SOC)]

1 post in this topic

Hi.
I have a little problem.

I modified the file restart to display messages on the server wasteland.

Everything was ok but to restart always is followed 20 minutes after the time, no matter what I do.

I have tried over time "serverTime, diag_Ticktime, time"
Always the same problem.

Maybe someone knows, what the problem is and being able to help me.

Sorry for my bad eng..

 

Spoiler

/*=================================================================================================================
  Timed Restart Script
  
  by Weeks
 [15thMEU(SOC)]
 edited by Vadi
 [Fearless TEAM]
=================================================================================================================*/

ServerDuration = (4 * 60 * 60);

private ["_timeStart","_timeSinceStart","_restartpassed","_shutdownSuccess","_msg30mins","_msg15mins","_msg5mins","_timeUntilRestart","_30minspassed","_15minspassed","_5minspassed","_60secondspassed"];


_msg30mins = "<t color='#FFFF00' size='1.25'>Server Restart</t><br/> The server will shut down in less than 30 minutes.";
_msg15mins = "<t color='#FF9D47' size='1.25'>Server Restart</t><br/> The server will shut down in less than 15 minutes.";
_msg5mins = "<t color='#FF5500' size='1.25'>Server Restart</t><br/> The server will shut down in less than 5 minutes.";
_msg1mins = "<t color='#FF0000' size='1.25'>Server Restart</t><br/> The server will shut down in less than 60 seconds! LOG OUT NOW!";

_30minspassed = false;
_15minspassed = false;
_5minspassed = false;
_60secondspassed = false;
_restartpassed = false; 
_onScreenTime = 6; 

_timeStart = time;

while{true} do
{
        
        _timeUntilRestart = ServerDuration - time;

    
    switch true do
    {
        case ((_timeUntilRestart < (1 * 60)) && !_60secondspassed) : 
        {    
            
            _role1 = "RESTART SERWERA";
            _role1names = ["ZA 1 MINUTĘ"];

            {
            _memberFunction = _x select 0;
            _memberNames = _x select 1;
            _finalText = format ["<t size='0.45' color='#C80000' align='right'>%1<br /></t>", _memberFunction];
            _finalText = _finalText + "<t size='0.65' color='#FFFFFF' align='right'>";
            {_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
            _finalText = _finalText + "</t>";
            [
            _finalText,
            [safezoneX + safezoneW - 0.8,0.50],    //DEFAULT: 0.5,0.35
            [safezoneY + safezoneH - 0.8,0.7],     //DEFAULT: 0.8,0.7
            _onScreenTime,
            0.01
            ] spawn BIS_fnc_dynamicText;
            sleep 0.1;
            } forEach [
            //The list below should have exactly the same amount of roles as the list above
            [_role1, _role1names]  //make SURE the last one here does NOT have a , at the end
            ];
    
            diag_log "60 seconds until server restart.";
            _60secondspassed = true;
            _5minspassed = true;
            _15minspassed = true;
            _30minspassed = true;
        };
        case ((_timeUntilRestart < (5 * 60)) && !_5minspassed) : 
        {    
            
            _role2 = "RESTART SERWERA";
            _role2names = ["ZA 5 MINUT"];

            {
            _memberFunction = _x select 0;
            _memberNames = _x select 1;
            _finalText = format ["<t size='0.45' color='#C80000' align='right'>%1<br /></t>", _memberFunction];
            _finalText = _finalText + "<t size='0.65' color='#FFFFFF' align='right'>";
            {_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
            _finalText = _finalText + "</t>";
            [
            _finalText,
            [safezoneX + safezoneW - 0.8,0.50],    //DEFAULT: 0.5,0.35
            [safezoneY + safezoneH - 0.8,0.7],     //DEFAULT: 0.8,0.7
            _onScreenTime,
            0.01
            ] spawn BIS_fnc_dynamicText;
            sleep 0.1;
            } forEach [
            //The list below should have exactly the same amount of roles as the list above
            [_role2, _role2names]  //make SURE the last one here does NOT have a , at the end
            ];
    
            diag_log "5 minutes until server restart.";
            _5minspassed = true;
            _15minspassed = true;
            _30minspassed = true;
        };
        case ((_timeUntilRestart < (15 * 60)) && !_15minspassed) : 
        {    
            
            _role3 = "RESTART SERWERA";
            _role3names = ["ZA 15 MINUT"];

            {
            _memberFunction = _x select 0;
            _memberNames = _x select 1;
            _finalText = format ["<t size='0.45' color='#C80000' align='right'>%1<br /></t>", _memberFunction];
            _finalText = _finalText + "<t size='0.65' color='#FFFFFF' align='right'>";
            {_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
            _finalText = _finalText + "</t>";
            [
            _finalText,
            [safezoneX + safezoneW - 0.8,0.50],    //DEFAULT: 0.5,0.35
            [safezoneY + safezoneH - 0.8,0.7],     //DEFAULT: 0.8,0.7
            _onScreenTime,
            0.01
            ] spawn BIS_fnc_dynamicText;
            sleep 0.1;
            } forEach [
            //The list below should have exactly the same amount of roles as the list above
            [_role3, _role3names]  //make SURE the last one here does NOT have a , at the end
            ];
    
            diag_log "15 minutes until server restart.";
            _15minspassed = true;
            _30minspassed = true;
        };
        case ((_timeUntilRestart < (30 * 60)) && !_30minspassed) : 
        {    
            
            _role4 = "RESTART SERWERA";
            _role4names = ["ZA 30 MINUT"];
            {
            _memberFunction = _x select 0;
            _memberNames = _x select 1;
            _finalText = format ["<t size='0.45' color='#C80000' align='right'>%1<br /></t>", _memberFunction];
            _finalText = _finalText + "<t size='0.65' color='#FFFFFF' align='right'>";
            {_finalText = _finalText + format ["%1<br />", _x]} forEach _memberNames;
            _finalText = _finalText + "</t>";
            [
            _finalText,
            [safezoneX + safezoneW - 0.8,0.50],    //DEFAULT: 0.5,0.35
            [safezoneY + safezoneH - 0.8,0.7],     //DEFAULT: 0.8,0.7
            _onScreenTime,
            0.01
            ] spawn BIS_fnc_dynamicText;
            sleep 0.1;
            } forEach [
            //The list below should have exactly the same amount of roles as the list above
            [_role4, _role4names]  //make SURE the last one here does NOT have a , at the end
            ];
    
            diag_log "30 minutes until server restart.";
            _30minspassed = true;
        };
    };
    if(time > ServerDuration) then
    {
        diag_log "Restart timeout elapsed, attempting server shutdown.";
        _shutdownSuccess = "admin" serverCommand "#restart";
        if(_shutdownSuccess) then
        {
            diag_log "Shutting down server!";
        }
        else
        {
            diag_log "Shutdown failed!";
        };
        
    };
    sleep 1;
};
 

 

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.