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
Don't forget to change the ServerCommandPassword in this line of the fn_restart.sqf
Code:
"CE8C283FB8EDDA1F89B3BD5C7EBE8" serverCommand "#restartserver";
Code:
class getRealTime {};
class restart {};
fn_getRealTime.sqf
Code:
/*
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
Code:
/*
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;
};
Code:
EXTDB "9:LOCK";
Code:
realTimeSippe = [];
[] spawn TON_fnc_getRealTime;
[] spawn TON_fnc_restart;
Code:
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
Code:
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"
};
};
Code:
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;
};
Code:
F(bis_fnc_showNotification,ANYONE)
Hope I dont miss anything
Dernière édition par un modérateur: