Mission Parameter and small tweaks

* Moved the script in the server folder
* Catch if not called by a dedicated server
* Replace execVM with spawn in init_server.sqf
* Added german strings
This commit is contained in:
Christian 2017-08-17 17:39:11 +02:00
parent 570bfefc22
commit 22bd801dab
6 changed files with 36 additions and 27 deletions

View File

@ -25,7 +25,6 @@ switch (KP_liberation_preset) do {
if (isServer) then {
[] call compileFinal preprocessFileLineNumbers "scripts\server\init_server.sqf";
ExecVM "server_restart.sqf";
};
if (!isDedicated && !hasInterface && isMultiplayer) then {

View File

@ -1,14 +1,8 @@
ServerDuration = (3*60*60); // Timer , Default is 10800 seconds (3 Hours)
DebugServerDuration = (20 * 20);// Debug Timer
if (!isDedicated) exitWith {};
private ["_timeStart","_timeSinceStart","_shutdownSuccess","_isDebug","_timeUntilRestart","_30minspassed","_15minspassed","_5minspassed","_60secondspassed"];
private ["_serverDuration","_timeStart","_timeSinceStart","_shutdownSuccess","_timeUntilRestart","_30minspassed","_15minspassed","_5minspassed","_60secondspassed"];
_isDebug = false;
if(_isDebug) then
{
ServerDuration = DebugServerDuration;
};
_serverDuration = (KP_liberation_restart * 60 * 60);
_30minspassed = false;
_15minspassed = false;
@ -20,19 +14,14 @@ _timeStart = diag_tickTime;
while{true} do
{
_timeSinceStart = diag_tickTime - _timeStart;
_timeUntilRestart = ServerDuration - _timeSinceStart;
if(_isDebug) then
{
diag_log format ["Time Since Start: %1, Time Until Restart: %2", _timeSinceStart, _timeUntilRestart];
};
_timeUntilRestart = _serverDuration - _timeSinceStart;
switch true do
{
case ((_timeUntilRestart < (1 * 60)) && !_60secondspassed) :
{
["lib_restart_60_s"] remoteExecCall ["BIS_fnc_showNotification"];
diag_log "60 seconds until server restart.";
diag_log "[KP LIBERATION] [RESTART] 60 seconds until server restart.";
_60secondspassed = true;
_5minspassed = true;
_15minspassed = true;
@ -41,7 +30,7 @@ while{true} do
case ((_timeUntilRestart < (5 * 60)) && !_5minspassed) :
{
["lib_restart_5_min"] remoteExecCall ["BIS_fnc_showNotification"];
diag_log "5 minutes until server restart.";
diag_log "[KP LIBERATION] [RESTART] 5 minutes until server restart.";
_5minspassed = true;
_15minspassed = true;
_30minspassed = true;
@ -49,35 +38,34 @@ while{true} do
case ((_timeUntilRestart < (15 * 60)) && !_15minspassed) :
{
["lib_restart_15_min"] remoteExecCall ["BIS_fnc_showNotification"];
diag_log "15 minutes until server restart.";
diag_log "[KP LIBERATION] [RESTART] 15 minutes until server restart.";
_15minspassed = true;
_30minspassed = true;
};
case ((_timeUntilRestart < (30 * 60)) && !_30minspassed) :
{
["lib_restart_30_min"] remoteExecCall ["BIS_fnc_showNotification"];
diag_log "30 minutes until server restart.";
diag_log "[KP LIBERATION] [RESTART] 30 minutes until server restart.";
_30minspassed = true;
};
};
if(_timeSinceStart > ServerDuration) then
if(_timeSinceStart > _serverDuration) then
{
diag_log "Restart timeout elapsed, attempting server shutdown.";
diag_log "[KP LIBERATION] [RESTART] Restart timeout elapsed, attempting server shutdown.";
sleep 5;
if isServer then {
_myPass = call compile preprocessFileLineNumbers "\userconfig\restart\myPass.hpp";
_shutdownSuccess = _myPass serverCommand "#restart";//you can change with #restartserver if you want to restart the server process(Windows Dedicated Only).
};
if(_shutdownSuccess) then
{
diag_log "Shutting down server!";
diag_log "[KP LIBERATION] [RESTART] Shutting down server!";
}
else
{
diag_log "Shutdown failed!";
diag_log "[KP LIBERATION] [RESTART] Shutdown failed!";
};
};
sleep 15;
};

View File

@ -87,4 +87,9 @@ if (KP_liberation_ailogistics) then {[] spawn compileFinal preprocessFileLineNum
};
} foreach allUnits;
// Server Restart Script from K4s0
if (KP_liberation_restart > 0) then {
[] spawn compileFinal preprocessFileLineNumbers "scripts\server\game\server_restart.sqf";
};
if (KP_liberation_debug) then {private _text = format ["[KP LIBERATION] [DEBUG] init_server.sqf done for: %1", debug_source];_text remoteExec ["diag_log",2];};

View File

@ -34,6 +34,7 @@ if ( isMultiplayer ) then {
KP_liberation_debug = ["DebugEnable",0] call bis_fnc_getParamValue;
KP_liberation_suppMod_enb = ["SuppMod",1] call BIS_fnc_getParamValue;
KP_liberation_cr_param_buildings = ["CR_Building",1] call BIS_fnc_getParamValue;
KP_liberation_restart = ["ServerRestart",0] call BIS_fnc_getParamValue;
} else {
GRLIB_difficulty_modifier = 2;
GRLIB_time_factor = 12;
@ -69,6 +70,7 @@ if ( isMultiplayer ) then {
KP_liberation_ace = 0;
KP_liberation_debug = 0;
KP_liberation_suppMod_enb = 1;
KP_liberation_restart = 0;
};
if ( GRLIB_fatigue < 0.1 ) then { GRLIB_fatigue = false } else { GRLIB_fatigue = true };

View File

@ -4256,23 +4256,32 @@
</Key>
<Key ID="STR_NOTIFICATION_RESTART_TITLE">
<Original>SERVER RESTART NOTIFICATION</Original>
<German>SERVER RESTART HINWEIS</German>
<Italian>NOTIFICA RESTART SERVER</Italian>
</Key>
<Key ID="STR_NOTIFICATION_RESTART_SECOND">
<Original>The server will restart in less than 60 seconds!</Original>
<German>Server Restart in weniger als 60 Sekunden!</German>
<Italian>Il server si riavvierà tra meno di 60 secodni!</Italian>
</Key>
<Key ID="STR_NOTIFICATION_RESTART_FIVE">
<Original>The server will restart in less than 5 minutes!</Original>
<German>Server Restart in weniger als 5 Minuten!</German>
<Italian>Il server si riavvierà tra meno di 5 minuti!</Italian>
</Key>
<Key ID="STR_NOTIFICATION_RESTART_FIFTEEN">
<Original>The server will restart in less than 15 minutes!</Original>
<German>Server Restart in weniger als 15 Minuten!</German>
<Italian>Il server si riavvierà tra meno di 15 minuti!</Italian>
</Key>
<Key ID="STR_NOTIFICATION_RESTART_THIRTY">
<Original>The server will restart in less than 30 minutes!</Original>
<German>Server Restart in weniger als 30 Minuten!</German>
<Italian>Il server si riavvierà tra meno di 30 minuti!</Italian>
</Key>
<Key ID="STR_RESTART_PARAM">
<Original>Automatic Server Restart after (hours)</Original>
<German>Automatischer Server Restart nach (Stunden)</German>
</Key>
</Package>
</Project>

View File

@ -298,6 +298,12 @@ class Params
texts[] = { $STR_PARAMS_DISABLED, $STR_PARAMS_ENABLED };
default = 0;
};
class ServerRestart {
title = $STR_RESTART_PARAM;
values[] = {0,1,2,3,4,5,6};
texts[] = {$STR_PARAMS_DISABLED,"1","2","3","4","5","6"};
default = 0;
};
class WipeSave1 {
title = $STR_WIPE_TITLE;
values[] = {0,1};