Advertisement
Guest User

Untitled

a guest
Mar 11th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  1. //nul = [this] execVM "fillCrate.sqf";
  2.  
  3. /*
  4. @file Version: v0.2
  5. @file name: fillCrate.sqf
  6. @file Author: TAW_Tonic
  7. @file edit: 3/8/2013
  8. @file Description: Automatically fill ammo box with everything in the game depending on paramenters
  9. @params: [box,type,bool (optional),seconds(optional default: 5min)] execVM "fillCrate.sqf
  10. @examples:
  11. nul = [this,0,true] execVM "fillCrate.sqf"; //Fill ammo crate with everything - resupply enabled
  12. nul = [this,1,true] execVM "fillCrate.sqf"; //Fill ammo crate with weapons & magazines - resupply enabled
  13. nul = [this,2] execVM "fillCrate.sqf"; //Fill ammo crate with items - resupply disabled
  14. nul = [this,3,true,(60 * 2)] execVM "fillCrate.sqf"; //Fill ammo crate with backpacks - resupply enabled - resupply every 2 minutes
  15. */
  16. private["_box","_type","_boxn","_bType","_bType","_bPos","_boxn","_cfgweapons","_weapons","_magazines","_cur_wep","_classname","_wep_type","_scope","_picture","_items","_backpacks"];
  17. _box = _this select 0;
  18. _type = _this select 1;
  19. _resupply = if(count _this > 2) then {_this select 2;} else {false;};
  20. _resupply_time = if(count _this > 3) then {_this select 3;} else {60 * 5};
  21.  
  22. _bType = typeOf _box;
  23. _bPos = getPos _box;
  24.  
  25. //Hide the global ammo box & create a local one *temp fix for locality issues).
  26. if(!local _box) then
  27. {
  28. _box hideObject true;
  29. _boxn = _bType createVehicleLocal [0,0,0];
  30. _boxn setPosATL [_bPos select 0,_bPos select 1,0];
  31.  
  32. }
  33. else
  34. {
  35. _boxn = _box;
  36. };
  37.  
  38. clearWeaponCargo _boxn;
  39. clearMagazineCargo _boxn;
  40. clearItemCargo _boxn;
  41. clearBackpackCargo _boxn;
  42.  
  43. switch (_type) do
  44. {
  45. //Master ammo crate (EVERYTHING).
  46. case 0:
  47. {
  48. _cfgweapons = configFile >> "CfgWeapons";
  49. _weapons = [];
  50.  
  51. for "_i" from 0 to (count _cfgWeapons)-1 do
  52. {
  53. _cur_wep = _cfgweapons select _i;
  54.  
  55. if(isClass _cur_wep) then
  56. {
  57. _classname = configName _cur_wep;
  58. _wep_type = getNumber(_cur_wep >> "type");
  59. _scope = getNumber(_cur_wep >> "scope");
  60. _picture = getText(_cur_wep >> "picture");
  61. if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
  62. {
  63. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  64. _weapons set[count _weapons, _classname];
  65. };
  66. };
  67. };
  68.  
  69. _cfgweapons = configFile >> "CfgMagazines";
  70. _magazines = [];
  71.  
  72. for "_i" from 0 to (count _cfgWeapons)-1 do
  73. {
  74. _cur_wep = _cfgweapons select _i;
  75.  
  76. if(isClass _cur_wep) then
  77. {
  78. _classname = configName _cur_wep;
  79. //_wep_type = getNumber(_cur_wep >> "type");
  80. _scope = getNumber(_cur_wep >> "scope");
  81. _picture = getText(_cur_wep >> "picture");
  82. if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
  83. {
  84. _magazines set[count _magazines, _classname];
  85. };
  86. };
  87. };
  88.  
  89. { _boxn addWeaponCargo [_x,50]; } foreach _weapons;
  90. { _boxn addMagazineCargo [_x,50]; }foreach _magazines;
  91.  
  92. _cfgweapons = configFile >> "CfgWeapons";
  93. _items = [];
  94.  
  95. for "_i" from 0 to (count _cfgWeapons)-1 do
  96. {
  97. _cur_wep = _cfgweapons select _i;
  98.  
  99. if(isClass _cur_wep) then
  100. {
  101. _classname = configName _cur_wep;
  102. _wep_type = getNumber(_cur_wep >> "type");
  103. _scope = getNumber(_cur_wep >> "scope");
  104. _picture = getText(_cur_wep >> "picture");
  105. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  106. if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
  107. {
  108. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  109. _items set[count _items, _classname];
  110. };
  111. };
  112. };
  113.  
  114. { _boxn addItemCargo [_x,50]; } foreach _items;
  115.  
  116. _cfgweapons = configFile >> "CfgVehicles";
  117. _backpacks = [];
  118.  
  119. for "_i" from 0 to (count _cfgWeapons)-1 do
  120. {
  121. _cur_wep = _cfgweapons select _i;
  122.  
  123. if(isClass _cur_wep) then
  124. {
  125. _classname = configName _cur_wep;
  126. _wep_type = getText(_cur_wep >> "vehicleClass");
  127. _scope = getNumber(_cur_wep >> "scope");
  128. _picture = getText(_cur_wep >> "picture");
  129. if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
  130. {
  131. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  132. _backpacks set[count _backpacks, _classname];
  133. };
  134. };
  135. };
  136.  
  137. { _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
  138. };
  139. //Fill box with Guns & Ammo only
  140. case 1:
  141. {
  142. _cfgweapons = configFile >> "CfgWeapons";
  143. _weapons = [];
  144.  
  145. for "_i" from 0 to (count _cfgWeapons)-1 do
  146. {
  147. _cur_wep = _cfgweapons select _i;
  148.  
  149. if(isClass _cur_wep) then
  150. {
  151. _classname = configName _cur_wep;
  152. _wep_type = getNumber(_cur_wep >> "type");
  153. _scope = getNumber(_cur_wep >> "scope");
  154. _picture = getText(_cur_wep >> "picture");
  155. if(_scope >= 2 && _wep_type in [1,2,4,4096] && _picture != "" && !(_classname in _weapons) && _classname != "NVGoggles") then
  156. {
  157. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  158. _weapons set[count _weapons, _classname];
  159. };
  160. };
  161. };
  162.  
  163. _cfgweapons = configFile >> "CfgMagazines";
  164. _magazines = [];
  165.  
  166. for "_i" from 0 to (count _cfgWeapons)-1 do
  167. {
  168. _cur_wep = _cfgweapons select _i;
  169.  
  170. if(isClass _cur_wep) then
  171. {
  172. _classname = configName _cur_wep;
  173. //_wep_type = getNumber(_cur_wep >> "type");
  174. _scope = getNumber(_cur_wep >> "scope");
  175. _picture = getText(_cur_wep >> "picture");
  176. if(_scope >= 2 && _picture != "" && !(_classname in _magazines)) then
  177. {
  178. _magazines set[count _magazines, _classname];
  179. };
  180. };
  181. };
  182.  
  183. { _boxn addWeaponCargo [_x,50]; } foreach _weapons;
  184. { _boxn addMagazineCargo [_x,50]; }foreach _magazines;
  185. };
  186.  
  187. //Items only
  188. case 2:
  189. {
  190. _cfgweapons = configFile >> "CfgWeapons";
  191. _items = [];
  192.  
  193. for "_i" from 0 to (count _cfgWeapons)-1 do
  194. {
  195. _cur_wep = _cfgweapons select _i;
  196.  
  197. if(isClass _cur_wep) then
  198. {
  199. _classname = configName _cur_wep;
  200. _wep_type = getNumber(_cur_wep >> "type");
  201. _scope = getNumber(_cur_wep >> "scope");
  202. _picture = getText(_cur_wep >> "picture");
  203. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  204. if(_scope >= 2 && _wep_type in [131072,4096] && _picture != "" && !(_classname in _items) && _classname != "Binocular") then
  205. {
  206. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  207. _items set[count _items, _classname];
  208. };
  209. };
  210. };
  211.  
  212. { _boxn addItemCargo [_x,50]; } foreach _items;
  213. };
  214.  
  215. case 3:
  216. {
  217.  
  218. _cfgweapons = configFile >> "CfgVehicles";
  219. _backpacks = [];
  220.  
  221. for "_i" from 0 to (count _cfgWeapons)-1 do
  222. {
  223. _cur_wep = _cfgweapons select _i;
  224.  
  225. if(isClass _cur_wep) then
  226. {
  227. _classname = configName _cur_wep;
  228. _wep_type = getText(_cur_wep >> "vehicleClass");
  229. _scope = getNumber(_cur_wep >> "scope");
  230. _picture = getText(_cur_wep >> "picture");
  231. if(_scope >= 2 && _wep_type == "Backpacks" && _picture != "" && !(_classname in _backpacks)) then
  232. {
  233. //diag_log format["Class: %1 - Type: %2 - Scope: %3 - Pic: %4 - WEP: %5",_classname,_wep_type,_scope,_picture,_cur_wep];
  234. _backpacks set[count _backpacks, _classname];
  235. };
  236. };
  237. };
  238.  
  239. { _boxn addBackPackCargo [_x,5]; } foreach _backpacks;
  240. };
  241. };
  242.  
  243. if(_resupply) then
  244. {
  245. sleep _resupply_time;
  246. [_boxn,_type,_resupply,_resupply_time] execVM "fillCrate.sqf";
  247. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement