Advertisement
MulleDK19

ARMA 3 Alpha - Instant reload workaround script

Mar 12th, 2013
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. //////////
  2. /// INSTANT LOADING
  3. /// Version: 2
  4. /// Author: Morten a.k.a. MulleDK19 ©
  5. /////
  6. /// This is a workaround for a bug causing the entire game world to be reloaded if certain blufor weapons are used.
  7. /////
  8. /////
  9. /// Usage:
  10. ///     The script takes one optional parameter, which is whether to black out while it performs its job. The parameter defaults to true. Use one of the following:
  11. ///     execVM "instant_loading.sqf";
  12. ///     true execVM "instant_loading.sqf";
  13. ///     false execVM "instant_loading.sqf";
  14. /////
  15.  
  16. private ["_blackOut", "_weapons", "_magazines", "_getUnitInfo", "_unitInfo", "_unit"];
  17. if (!isNil "_this") then
  18. {
  19.     _blackOut = _this;
  20. };
  21.  
  22. if (isNil "_blackOut") then
  23. {
  24.     _blackOut = true;
  25. };
  26.  
  27. if (_blackOut) then
  28. {
  29.     titleText ["", "BLACK FADED"];
  30. };
  31.  
  32. if (isServer || !isMultiplayer) then
  33. {
  34.     _unitInfos = [];
  35.     {
  36.         if (side _x == blufor) then
  37.         {
  38.             _unit = _x;
  39.             _weapons = weapons _x;
  40.             _magazines = magazines _x;
  41.            
  42.             {
  43.                 _unit removeWeapon _x;
  44.             } forEach _weapons;
  45.             _unitInfos = _unitInfos + [[_x, _weapons, _magazines]];
  46.         };
  47.     } forEach allUnits;
  48.    
  49.     IL_UnitInfos = _unitInfos;
  50.    
  51.     if (isMultiplayer) then
  52.     {
  53.         publicVariable "IL_UnitInfos";
  54.     };
  55. }
  56. else
  57. {
  58.     {
  59.         _unit = _x;
  60.         if (side _x == blufor) then
  61.         {
  62.             {
  63.                 _unit removeWeapon _x;
  64.             } forEach weapons _unit;
  65.         };
  66.     } forEach allUnits;
  67. };
  68.  
  69. waitUntil { !isNil "IL_UnitInfos" };
  70. sleep (if (isMultiplayer) then { 3 } else { 0.5 });
  71.  
  72. IL_fnc_getUnitInfo =
  73. {
  74.     private ["_unit", "_unitInfo"];
  75.     _unit = _this;
  76.     {
  77.         scopeName "loop1";
  78.         if (_x select 0 == _unit) then
  79.         {
  80.             _unitInfo = _x;
  81.             breakOut "loop1";
  82.         };
  83.     } forEach IL_UnitInfos;
  84.    
  85.     _unitInfo;
  86. };
  87.  
  88. {
  89.     if (side _x == blufor) then
  90.     {
  91.         _unit = _x;
  92.         _unitInfo = _unit call IL_fnc_getUnitInfo;
  93.         _weapons = _unitInfo select 1;
  94.        
  95.         {
  96.             _unit addWeapon _x;
  97.         } forEach _weapons;
  98.        
  99.         reload _unit;
  100.     };
  101. } forEach allUnits;
  102.  
  103. IL_UnitInfos = nil;
  104.  
  105. if (!isMultiplayer) then
  106. {
  107.     setAccTime 8;
  108.     sleep 5;
  109.     setAccTime 1;
  110. }
  111. else
  112. {
  113.     sleep 5;
  114. };
  115.  
  116. if (_blackOut) then
  117. {
  118.     titleText ["", "BLACK IN"];
  119. };
  120. /// INSTANT LOADING
  121. //////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement