fn_loadGear.sqf 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "macro.sqf"
  2. /*
  3. @version: 1.4
  4. @file_name: fn_loadGear.sqf
  5. @file_author: TAW_Tonic
  6. @file_edit: 7/9/2013
  7. @file_description: Load saved gear in old VAS format.
  8. */
  9. private["_slot","_loadout","_primary","_launcher","_handgun","_magazines","_uniform","_vest","_backpack","_items","_primitems","_secitems","_handgunitems","_uitems","_vitems","_bitems","_handle"];
  10. if(!isNil {VAS_loadout_ip}) exitWith {};
  11. _slot = if(isNil {_this select 0}) then {lbCurSel VAS_load_list} else {_this select 0};
  12. if(_slot == -1) exitWith {hint "You didn't select a slot to load!";};
  13. if(vas_disableLoadSave) then
  14. {
  15. _loadout = missionNamespace getVariable format["vas_gear_new_%1",_slot];
  16. }
  17. else
  18. {
  19. _loadout = profileNamespace getVariable format["vas_gear_new_%1",_slot];
  20. };
  21. if(isNil {_loadout}) exitWith {}; //Slot data doesn't exist
  22. VAS_loadout_ip = true;
  23. _primary = _loadout select 1;
  24. _launcher = _loadout select 2;
  25. _handgun = _loadout select 3;
  26. _magazines = _loadout select 4;
  27. _uniform = _loadout select 5;
  28. _vest = _loadout select 6;
  29. _backpack = _loadout select 7;
  30. _items = _loadout select 8;
  31. _primitems = _loadout select 9;
  32. _secitems = _loadout select 10;
  33. _handgunitems = _loadout select 11;
  34. _uitems = _loadout select 12;
  35. _vitems = _loadout select 13;
  36. _bitems = _loadout select 14;
  37. //Strip the unit down
  38. RemoveAllWeapons player;
  39. {player removeMagazine _x;} foreach (magazines player);
  40. removeUniform player;
  41. removeVest player;
  42. removeBackpack player;
  43. removeGoggles player;
  44. removeHeadGear player;
  45. {
  46. player unassignItem _x;
  47. player removeItem _x;
  48. } foreach (assignedItems player);
  49. //Add the gear
  50. if(_uniform != "") then {_handle = [_uniform,true,nil,nil,nil] spawn VAS_fnc_handleItem; waitUntil {scriptDone _handle};};
  51. if(_vest != "") then {_handle = [_vest,true,nil,nil,nil] spawn VAS_fnc_handleItem; waitUntil {scriptDone _handle};};
  52. if(_backpack != "") then {_handle = [_backpack,true,nil,nil,nil] spawn VAS_fnc_handleItem; waitUntil {scriptDone _handle};};
  53. {
  54. _handle = [_x,true,nil,nil,nil] spawn VAS_fnc_handleItem;
  55. waitUntil {scriptDone _handle};
  56. } foreach _magazines;
  57. if(_primary != "") then {[_primary,true,nil,nil,nil] spawn VAS_fnc_handleItem;};
  58. if(_launcher != "") then {[_launcher,true,nil,nil,nil] spawn VAS_fnc_handleItem;};
  59. if(_handgun != "") then {[_handgun,true,nil,nil,nil] spawn VAS_fnc_handleItem;};
  60. {_handle = [_x,true,nil,nil,nil] spawn VAS_fnc_handleItem; waitUntil {scriptDone _handle};} foreach _items;
  61. {[_x,true,nil,nil,true] call VAS_fnc_handleItem;} foreach (_uitems);
  62. {[_x,true,nil,nil,true] call VAS_fnc_handleItem;} foreach (_vitems);
  63. {[_x,true,true,nil,nil] call VAS_fnc_handleItem;} foreach (_bitems);
  64. {[_x,true,nil,true,nil] call VAS_fnc_handleItem;} foreach (_primitems);
  65. {[_x,true,nil,true,nil] call VAS_fnc_handleItem;} foreach (_secitems);
  66. {[_x,true,nil,true,nil] call VAS_fnc_handleItem;} foreach (_handgunitems);
  67. if(primaryWeapon player != "") then
  68. {
  69. player selectWeapon (primaryWeapon player);
  70. };
  71. VAS_loadout_ip = nil;