EN |Scripted Restart

Topic created · 20 Posts · 306 Views
  • In this topic, I will show you how to restart your Server without any need of extra Programm.
    Don't forget to change the ServerCommandPassword in this line of the fn_restart.sqf

    "CE8C283FB8EDDA1F89B3BD5C7EBE8" serverCommand "#restartserver";
    

    First create 2 new files and add them to the config.cpp under the tag "TON"

    class getRealTime {};
    class restart {};
    

    fn_getRealTime.sqf

    /*
    	Autor: ԄӏՖҚ 
    	Written for Die-Sippe
    
    	Gets the realtime if call it
    */
    for "_i" from 0 to 1 step 0 do {
        realTimeSippe = "extDB3" callExtension "9:LOCAL_TIME";
        realTimeSippe = call compile realTimeSippe;
        publicVariable "realTimeSippe";
        sleep 0.1;
    };
    

    fn_restart.sqf

    /*
    	author: ԄӏՖҚ
    	description: Regelt die Restarts.
    	returns: nothing
    */
    waitUntil{!(realTimeSippe isEqualTo [])};
    //Set Vars once so they don't get called every time just once.
    private _configRestartHours = getArray(missionConfigFile >> "RestartTime" >> "times" >> "RestartTimeHours");
    private _configWarnTimeHours = getArray(missionConfigFile >> "RestartTime" >> "times" >> "WarnTimeHours");
    private _configWarnTimeMinutes = getArray(missionConfigFile >> "RestartTime" >> "times" >> "WarnTimeMinutes");
    private _configText = getArray(missionConfigFile >> "RestartTime" >> "text");
    _configRestartHours params [
        "_configRestartHoursOne",
        "_configRestartHoursTwo",
        "_configRestartHoursThree",
        "_configRestartHoursFour"
    ];
    _configWarnTimeHours params [
        "_warnTimeHourOne",
        "_warnTimeHourTwo",
        "_warnTimeHourThree",
        "_warnTimeHourFour"
    ];
    _configWarnTimeMinutes params [
        "_warnTimeMinuteOne",
        "_warnTimeMinuteTwo",
        "_warnTimeMinuteThree",
        "_warnTimeMinuteFour",
        "_warnTimeMinuteFive"
    ];
    _configText params[
        "_configTextOne",
        "_configTextTwo",
        "_configTextThree",
        "_configTextFour",
        "_configTextFive"
    ];
    life_warnOne = true;
    life_warnTwo = true;
    life_warnThree = true;
    life_warnFour = true;
    life_warnFive = true;
    for "_i" from 0 to 1 step 0 do {
        private _times = realTimeSippe select 1;
        private _Stunde = _times select 3;
        private _Minute = _times select 4;
        if(_Stunde in [_warnTimeHourOne, _warnTimeHourTwo, _warnTimeHourThree, _warnTimeHourFour])then{
            //Restart Warn 1
            if(_Minute isEqualTo _warnTimeMinuteOne && life_warnOne)then
            {
    			diag_log format["Warn 1: %1 Minute %2", _configTextOne, _warnTimeMinuteOne];
                ["restart",[_configTextOne]] remoteExecCall ['bis_fnc_showNotification',0];
                life_warnOne = false;
            };
            //Restart Warn 2
            if(_Minute isEqualTo _warnTimeMinuteTwo && life_warnTwo)then
            {
    			diag_log format["Warn 2: %1 Minute %2", _configTextTwo, _warnTimeMinuteTwo];
                ["restart",[_configTextTwo]] remoteExecCall ['bis_fnc_showNotification',0];
                life_warnTwo = false;
            };
            //Restart Warn 3
            if(_Minute isEqualTo _warnTimeMinuteThree && life_warnThree)then
            {
    			diag_log format["Warn 3: %1 Minute %2", _configTextThree, _warnTimeMinuteThree];
                ["restart",[_configTextThree]] remoteExecCall ['bis_fnc_showNotification',0];
                life_warnThree = false;
            };
            //Restart Warn 4
            if(_Minute isEqualTo _warnTimeMinuteFour && life_warnFour)then
            {
    			diag_log format["Warn 4: %1 Minute %2", _configTextFour, _warnTimeMinuteFour];
                ["restart",[_configTextFour]] remoteExecCall ['bis_fnc_showNotification',0];
                life_warnFour = false;
            };
            //Restart Warn 5
            if(_Minute isEqualTo _warnTimeMinuteFive && life_warnFive)then
            {
    			diag_log format["Warn 5: %1 Minute %2", _configTextFive, _warnTimeMinuteFive];
                ["restart",[_configTextFive]] remoteExecCall ['bis_fnc_showNotification',0];
                life_warnFive = false;
            };
        };	
        //Actual Restart
        if(_Stunde in[_configRestartHoursOne,_configRestartHoursTwo,_configRestartHoursThree,_configRestartHoursFour] && _Minute isEqualTo 0)then
        {
            "CE8C283FB8EDDA1F89B3BD5C7EBE8" serverCommand "#restartserver";
        };
        sleep 5;
    };
    

    call both files in your init.sqf of your life_server befor

    EXTDB "9:LOCK";
    
    realTimeSippe = [];
    [] spawn TON_fnc_getRealTime;
    [] spawn TON_fnc_restart;
    

    Should look like

    if (isNil {uiNamespace getVariable "life_sql_id"}) then {
        life_sql_id = round(random(9999));
        CONSTVAR(life_sql_id);
        uiNamespace setVariable ["life_sql_id",life_sql_id];
            try {
            _result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")];
            if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
            _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
            if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
        } catch {
            diag_log _exception;
            _extDBNotLoaded = [true, _exception];
        };
        if (_extDBNotLoaded isEqualType []) exitWith {};
    realTimeSippe = [];
    	[] spawn TON_fnc_getRealTime;
    	[] spawn TON_fnc_restart;
        EXTDB "9:LOCK";
        diag_log "extDB3: Connected to Database";
    } else {
        life_sql_id = uiNamespace getVariable "life_sql_id";
        CONSTVAR(life_sql_id);
        diag_log "extDB3: Still Connected to Database";
    };
    

    create a new config in your mission and call it Config_Restart.hpp
    this file needs to be included in your Config_Master.hpp

    class RestartTime 
    {
        class times
        {
            RestartTimeHours[] = {
    			6,
    			12,
    			18,
    			0    
            };
            /* Warn examples 5:00, 5:15, 5:30, 5:45, 5:55 */        
            WarnTimeHours[] = {
    			5,
    			11,
    			17,
    			23       
            };
            WarnTimeMinutes[] = {
    			0,
    			15,
    			30,
    			45,
    			55
            };                
        };
        text[] = {
            "Neustart in 60 Minuten! Zeiten 6 Uhr, 12 Uhr, 18 Uhr, 24Uhr",
            "Neustart in 45 Minuten! Zeiten 6 Uhr, 12 Uhr, 18 Uhr, 24Uhr",
            "Neustart in 30 Minuten! Zeiten 6 Uhr, 12 Uhr, 18 Uhr, 24Uhr",
            "Neustart in 15 Minuten! Zeiten 6 Uhr, 12 Uhr, 18 Uhr, 24Uhr",
            "Neustart in 5 Minuten! Zeiten 6 Uhr, 12 Uhr, 18 Uhr, 24Uhr"
        };
    };
    

    in your description.ext under class CfgNotifications add

        class restart
        {
        	title = "RESTART";
        	iconPicture = "\A3\ui_f\data\map\mapcontrol\taskIcon_ca.paa";
        	color[] = {0,0.8,0,1};
        	description = "%1";
        	duration = 10;
        	priority = 6;
        };  
    

    in your CfgRemoteExec.hpp add this line

    F(bis_fnc_showNotification,ANYONE)
    

    thats it for this.
    hope I dont miss anything

  • I get this error In the RPT

     3:10:29 Error in expression <qf [TON_fnc_restart]"
    
    
    
    
    
    waitUntil{!(realTimeSippe isEqualTo [])};
    
    private _>
     3:10:29   Error position: <realTimeSippe isEqualTo [])};
    
    private _>
     3:10:29   Error Undefined variable in expression: realtimesippe
     3:10:29 File \life_server\Functions\Systems\fn_restart.sqf [TON_fnc_restart], line 6
    
  • @Risk Maybe it is necessary to define realTimeSippe as an empty array at the beginning of the script

  • add both calls befor the

    EXTDB "9:LOCK";
    

    I updatet the topic with this.

  • @Risk I got a new error lol and I did everything as you put it. It Also broke the messages, now they are not even showing. Before they would show but just had that error in the RPT. 🙂

    2019/04/06, 22:33:05 Error in expression <f [TON_fnc_restart]"
    
    
    
    
    
    waitUntil {!(realTimeSippe isEqualTo [])};
    
    private _>
    2019/04/06, 22:33:05   Error position: <realTimeSippe isEqualTo [])};
    
    private _>
    2019/04/06, 22:33:05   Error Undefined variable in expression: realtimesippe
    2019/04/06, 22:33:05 File \life_server\Functions\Systems\fn_restart.sqf [TON_fnc_restart], line 6
    
  • @Risk any idea?

  • @IceEagle132 Can you show me your init.sqf of your life_server ?

  • @IceEagle132 I'll look into on my side, I'll keep you informed 😃

  • @IceEagle132 You use extDB3 or extDB2 ?

  • @Maloma said in EN |Scripted Restart:

    extDB3

    extDB3

  • @IceEagle132
    I use it with extDB2 and it works so I'm sorry but I do not see any problem for you

  • @Risk
    Great tutorial thanks for doing

  • @Maloma Iv done it with fresh install still no dice.

  • @IceEagle132 I am looking at your problem but you would have more details. (your operating system of your server and your life version Altis)

  • @Maloma Windows server 2012 - AL 5.0 😉

  • @IceEagle132
    I’m sorry, but I can’t find your problem.
    But for me it probably comes from your extdb3 which must be badly configured.

    You can try reinstalling from zero extdb3 and don’t change the name.

    Because in your error it says that the variable "realTimeSippe" has not defined, which can either come from your extdb3 or from your file "fn_getRealTime.sqf".

  • @Risk said in EN |Scripted Restart:

    fn_getRealTime.sqf
    /*
    Autor: ԄӏՖҚ
    Written for Die-Sippe

    Gets the realtime if call it
    */
    for "_i" from 0 to 1 step 0 do {
    realTimeSippe = "extDB3" callExtension "9:LOCAL_TIME";
    realTimeSippe = call compile realTimeSippe;
    publicVariable "realTimeSippe";
    sleep 0.1;
    };

    Is it possible to set the real-Time + Date as Game-Time after every Restart? So i see ingame always the real-Time? I have chande the timemodule so the Time isn´t run faster.

  • @Saturin78 You can set the time in game as faster as the real life and in the life_server/init.sqf set the real time in game.
    If you want to get help, create a new post here 😉

  • add realTimeSippe = []; befor the calls. Forget this 😄

Log in to reply