Advertisement
Brenner650

mcrs.sqf

Oct 27th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////
  2. // MCPC10's Arma 3 Restart Skript //
  3. // Copyright to MCPC10 //
  4. // File: mcrs.sqf //
  5. ///////////////////////////////////////////////////////////////////////////
  6.  
  7. #define HARDCODET_MINIMUM 300 // DO NOT CHANGE !!! (5 minutes)
  8.  
  9. //If the caller is not the server, exit here
  10. if (!isServer) exitWith {};
  11.  
  12. private["_restartTimeInterval","_restartTime","_sleepInterval","_msgTimeInterval", "_useMSG", "_password", "_useShutdown", "_startTime", "_timeUntilRestart", "_timeSinceStart"];
  13.  
  14. _restartTimeInterval = ["CfgSettings","MCRS_Settings","restartInterval"] call BIS_fnc_getCfgData;
  15. _sleepInterval = ["CfgSettings","MCRS_Settings","checkInterval"] call BIS_fnc_getCfgData;
  16. _msgTimeInterval = ["CfgSettings","MCRS_Settings","warnMsgInterval"] call BIS_fnc_getCfgData;
  17. _useMSG = ["CfgSettings","MCRS_Settings","useWarnMsg"] call BIS_fnc_getCfgData;
  18. //_password = ["CfgSettings","MCRS_Settings","serverCommandPassword"] call BIS_fnc_getCfgData;
  19. _password = call compile preprocessFileLineNumbers "\userConfig\myPass\myPass.hpp";
  20. _useShutdown = ["CfgSettings","MCRS_Settings","useShutdownCommand"] call BIS_fnc_getCfgData;
  21. _msg = ["CfgSettings","MCRS_Settings","warnMessage"] call BIS_fnc_getCfgData;
  22.  
  23. //Calculate the hours + minute value in only a second value
  24. _restartTime = (((_restartTimeInterval select 0) * 60) + (_restartTimeInterval select 1)) * 60;
  25.  
  26. //Get start time
  27. _startTime = diag_tickTime;
  28.  
  29. //Limit the value of _restartTimeInterval
  30. if((_restartTimeInterval select 1) < HARDCODET_MINIMUM) then
  31. {
  32. _restartTimeInterval set [1, HARDCODET_MINIMUM];
  33. };
  34.  
  35. //Remove unvalid msg values
  36. if(_useMSG isEqualTo 1) then
  37. {
  38. {
  39. //Check the message time intervals
  40. if(_x > _restartTime OR _x == 0) then
  41. {
  42. _msgTimeInterval deleteAt _forEachIndex;
  43. };
  44. } forEach _msgTimeInterval;
  45. };
  46.  
  47.  
  48. ///////////////////////////////////////////////////////////////////////////
  49. // Main loop //
  50. ///////////////////////////////////////////////////////////////////////////
  51. while {true} do {
  52.  
  53. _timeSinceStart = diag_tickTime - _startTime;
  54. _timeUntilRestart = _restartTime - _timeSinceStart;
  55.  
  56. //Message System
  57. if(_useMSG isEqualTo 1) then
  58. {
  59. {
  60. if((_timeUntilRestart <= _x) AND (_timeUntilRestart > _msgTimeInterval select (_forEachIndex +1))) then
  61. {
  62. //Show the message
  63. if(!isNil "_msg" OR "_msg" != "") then
  64. {
  65. _message = format [_msg, _timeUntilRestart];
  66. _message remoteExec ["systemchat"];
  67. };
  68.  
  69. _msgTimeInterval deleteAt _forEachIndex;
  70. };
  71. } forEach _msgTimeInterval;
  72. };
  73.  
  74. //Check if _uptime is higher than _restartTime
  75. if(_timeSinceStart >= _restartTime) then
  76. {
  77. if(_useShutdown isEqualTo 1) then
  78. {
  79. //Shutdown the server, so that FireDaemon, etc can restart the whole server
  80. _password serverCommand "#shutdown"
  81. };
  82. };
  83.  
  84. //Wait for x seconds
  85. uiSleep _sleepInterval;
  86. };
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement