Advertisement
MulleDK19

ARMA 3 Alpha - Instant reload workaround script - Version 4

Mar 14th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. //////////
  2. /// INSTANT LOADING
  3. /// Version: 4
  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", "_weapon", "_weaponItems", "_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.             _weapon = primaryWeapon _unit;
  40.             _weaponItems = primaryWeaponItems _unit;
  41.             _unit removeWeapon _weapon;
  42.             _unitInfos = _unitInfos + [[_x, _weapon, _weaponItems]];
  43.         };
  44.     } forEach allUnits;
  45.    
  46.     IL_UnitInfos = _unitInfos;
  47.    
  48.     if (isMultiplayer) then
  49.     {
  50.         publicVariable "IL_UnitInfos";
  51.     };
  52. }
  53. else
  54. {
  55.     {
  56.         _unit = _x;
  57.         if (side _x == blufor) then
  58.         {
  59.             _x removeWeapon primaryWeapon _x;
  60.         };
  61.     } forEach allUnits;
  62. };
  63.  
  64. waitUntil { !isNil "IL_UnitInfos" };
  65. sleep (if (isMultiplayer) then { 3 } else { 0.5 });
  66.  
  67. IL_fnc_getUnitInfo =
  68. {
  69.     private ["_unit", "_unitInfo"];
  70.     _unit = _this;
  71.     {
  72.         scopeName "loop1";
  73.         if (_x select 0 == _unit) then
  74.         {
  75.             _unitInfo = _x;
  76.             breakOut "loop1";
  77.         };
  78.     } forEach IL_UnitInfos;
  79.    
  80.     _unitInfo;
  81. };
  82.  
  83. {
  84.     if (side _x == blufor) then
  85.     {
  86.         _unit = _x;
  87.         _unitInfo = _unit call IL_fnc_getUnitInfo;
  88.         _weapon = _unitInfo select 1;
  89.         _weaponItems = _unitInfo select 2;
  90.        
  91.         _unit addWeapon _weapon;
  92.         _unit selectWeapon _weapon;
  93.        
  94.         {
  95.             if (_x != "") then
  96.             {
  97.                 _unit addPrimaryWeaponItem _x;
  98.             };
  99.         } forEach _weaponItems;
  100.        
  101.         reload _unit;
  102.     };
  103. } forEach allUnits;
  104.  
  105. IL_UnitInfos = nil;
  106.  
  107. if (!isMultiplayer) then
  108. {
  109.     setAccTime 8;
  110.     sleep 5;
  111.     setAccTime 1;
  112. }
  113. else
  114. {
  115.     sleep 5;
  116. };
  117.  
  118. if (_blackOut) then
  119. {
  120.     titleText ["", "BLACK IN"];
  121. };
  122. /// INSTANT LOADING
  123. //////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement