Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. private ["_warntimes","_warntime","_text"];
  2. restartTime = 4; // hours
  3. _warnTimes = [230, 120, 60, 30, 15, 10, 5, 3, 2, 1]; // minutes
  4.  
  5. if (!isServer) exitWith {};
  6.  
  7. restartTime = restartTime * 60 * 60; // convert to seconds
  8. publicVariable "restartTime";
  9.  
  10. waituntil {!isnil "globalRealtime"};
  11.  
  12. diag_log(format ["DEBUG RESTART MESSAGE || Inizializing || Servertime: %1 || Missiontime: %2 || Localtime: %3", servertime, time, globalRealtime]);
  13. {
  14. _warntime = restartTime - (_x * 60); // get time without remaining time until restart
  15. waituntil {globalRealtime > _warntime};
  16.  
  17. // print warning with remaining _x minutes
  18. diag_log(format ["DEBUG RESTART MESSAGE || Servertime: %1 || Missiontime: %2 || Localtime: %3 || Restart in %4", servertime, time, globalRealtime, _x]);
  19. _text = format ["SERVER RESTART IN %1 MINUTES", _x];
  20. [nil,nil,rTitleText,_text, "PLAIN",10] call RE;
  21. } forEach _warntimes;
  22.  
  23. // last warning 30 seconds before restart
  24. waituntil {globalRealtime > (restartTime-30)};
  25. diag_log(format ["DEBUG RESTART MESSAGE || Servertime: %1 || Missiontime: %2 || Localtime: %3 || near Restart", servertime, time]);
  26. _text = format ["Logout NOW!", _x];
  27. [nil,nil,rTitleText,_text, "PLAIN",10] call RE;
  28.  
  29. // exit the ArmA Server when the time has come
  30. waituntil {globalRealtime > restartTime};
  31. "terminator" callExtension "terminate";
  32.  
  33. // should never reach this point
  34. _text = format ["meh... Restart Failed Oo", _x];
  35. [nil,nil,rTitleText,_text, "PLAIN",10] call RE;
  36.  
  37. // hint format["Connected on Server since Serverstart : %1", serverTime - time]
  38. //_subTextColour = "#FF0000";
  39. //_mainTextColour = "#44a0A0";
  40. //_text = parseText format ["<t align='center' color='%1' shadow='2' size='1.75'>Server Reboot</t><br/><t align='center' color='%2'>---------------------------------</t><br/><t color='%2' size='1.0'>In %3 Minutes</t>", _mainTextColour, _subTextColour, _x];
  41. //[nil,nil,rHINT,_text] call RE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement