Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. /*
  2. Author: Bryan "Tonic" Boardwine
  3.  
  4. Description:
  5. Fetches all the players houses and sets them up.
  6. */
  7. private["_query","_houses"];
  8. if(_this == "") exitWith {};
  9.  
  10. _query = format["SELECT pid, pos, inventory, containers FROM houses WHERE pid='%1' AND owned='1'",_this];
  11. waitUntil{!DB_Async_Active};
  12. _houses = [_query,2,true] call DB_fnc_asyncCall;
  13.  
  14. _return = [];
  15. {
  16. _pos = call compile format["%1",_x select 1];
  17. _house = nearestBuilding _pos;
  18. _house allowDamage false;
  19. _containers = [];
  20. _house setVariable["slots",[],true];
  21. if(!isNil {(_house getVariable "containers")}) then {
  22. {if(!isNull _x) then {deleteVehicle _x;};} foreach (_house getVariable "containers");
  23. };
  24.  
  25. _trunk = [_x select 2] call DB_fnc_mresToArray;
  26. if(typeName _trunk == "STRING") then {_trunk = call compile format["%1", _trunk];};
  27. _containerData = [_x select 3] call DB_fnc_mresToArray;
  28. if(typeName _containerData == "STRING") then {_containerData = call compile format["%1", _containerData];};
  29. _house setVariable["Trunk",_trunk,true];
  30. {
  31. if(count _x == 0) exitWith {}; //No containers / items.
  32. _className = _x select 0;
  33. _weapons = (_x select 1) select 0;
  34. _magazines = (_x select 1) select 1;
  35. _items = (_x select 1) select 2;
  36. _backpacks = (_x select 1) select 3;
  37.  
  38. //Setup the variables
  39. _positions = [_house] call life_fnc_getBuildingPositions;
  40. _pos = [0,0,0];
  41.  
  42. {
  43. _slots = _house getVariable ["slots",[]];
  44. if(!(_forEachIndex in _slots)) exitWith {
  45. _slots pushBack _forEachIndex;
  46. _house setVariable["slots",_slots,true];
  47. _pos = _x;
  48. };
  49. } foreach _positions;
  50.  
  51. if(_pos isEqualTo [0,0,0]) exitWith {};
  52.  
  53. _container = createVehicle[_className,_pos,[],0,"NONE"];
  54. waitUntil{!isNil "_container"};
  55. _container setPosATL _pos;
  56. //_container enableSimulation false;
  57.  
  58. _containers pushBack _container;
  59. clearWeaponCargoGlobal _container;
  60. clearItemCargoGlobal _container;
  61. clearMagazineCargoGlobal _container;
  62. clearBackpackCargoGlobal _container;
  63. //Add weapons to the crate.
  64. {
  65. _weaponCount = (_weapons select 1) select _forEachIndex;
  66. _container addWeaponCargoGlobal [_x,_weaponCount];
  67. } foreach (_weapons select 0);
  68.  
  69. //Add magazines
  70. {
  71. _magazineCount = (_magazines select 1) select _forEachIndex;
  72. _container addMagazineCargoGlobal [_x,_magazineCount];
  73. } foreach (_magazines select 0);
  74.  
  75. //Add items
  76. {
  77. _itemCount = (_items select 1) select _forEachIndex;
  78. _container addItemCargoGlobal [_x,_itemCount];
  79. } foreach (_items select 0);
  80.  
  81. //Add backpacks
  82. {
  83. _backpackCount = (_backpacks select 1) select _forEachIndex;
  84. _container addBackpackCargoGlobal [_x,_backpackCount];
  85. } foreach (_backpacks select 0);
  86.  
  87. } foreach _containerData;
  88.  
  89. _house setVariable["containers",_containers,true];
  90. _return pushBack [_x select 1,_containers];
  91. } foreach _houses;
  92.  
  93. missionNamespace setVariable[format["houses_%1",_this],_return];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement