Advertisement
MulleDK19

ARMA 3 Alpha - Instant reload workaround script - Version 3

Mar 13th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 KB | None | 0 0
  1. //////////
  2. /// INSTANT LOADING
  3. /// Version: 3
  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", "_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.             _weapon = primaryWeapon _x;
  40.             _magazines = magazines _x;
  41.             _unit removeWeapon _weapon;
  42.             _unitInfos = _unitInfos + [[_x, _weapon, _magazines]];
  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.        
  90.         _unit addWeapon _weapon;
  91.         _unit selectWeapon _weapon;
  92.        
  93.         reload _unit;
  94.     };
  95. } forEach allUnits;
  96.  
  97. IL_UnitInfos = nil;
  98.  
  99. if (!isMultiplayer) then
  100. {
  101.     setAccTime 8;
  102.     sleep 5;
  103.     setAccTime 1;
  104. }
  105. else
  106. {
  107.     sleep 5;
  108. };
  109.  
  110. if (_blackOut) then
  111. {
  112.     titleText ["", "BLACK IN"];
  113. };
  114. /// INSTANT LOADING
  115. //////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement