Advertisement
Meowzors

player_changeCode.sqf

Apr 13th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. /*
  2. player_changeCode.sqf
  3. Meowzors change code script version 0.8
  4. 4-13-2014
  5. Usage: [_safe, _newCode] spawn player_changeCode;
  6. */
  7. DZE_ActionInProgress = true;
  8. _activatingPlayer = player;
  9.  
  10. _safe = _this select 0;
  11.  
  12. _classname = getText (configFile >> "CfgMagazines" >> _safe >> "ItemActions" >> "Build" >> "create");
  13. _text = getText (configFile >> "CfgVehicles" >> (typeOf _safe) >> "displayName");
  14.  
  15. //Grab _newCode array and break apart
  16. _newCode = _this select 1;
  17. _combination_1 = _newCode select 0;
  18. _combination_2 = _newCode select 1;
  19. _combination_3 = _newCode select 2;
  20.  
  21. // Format Combination
  22. _combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3];
  23.  
  24. //If object is a safe instead of a lockbox we need one more number...
  25. if ((typeOf _classname) == "VaultStorage") then {
  26. {
  27. _combination_4 = _newCode select 3;
  28. _combination = format["%1%2",_combination,_combination_4,];
  29.  
  30. };
  31.  
  32.  
  33. //Get variables from current safe
  34. _safeID = _safe getVariable["ObjectID","0"];
  35. _safeUID = _safe getVariable["ObjectUID","0"];
  36.  
  37. //Get Location from current safe
  38. _dir = direction _safe;
  39. _pos = _safe getVariable["OEMPos",(getposATL _safe)];
  40. //FOR SOME REASON THIS DOES NOT GET DISPLAYED... Probably part of our problem...
  41. hint format["ID = %1 UID = %2 DIR = %3 POS = %4 Classname = %5.",_safeID,_safeUID,_dir,_pos, _classname];
  42. //Get cargo from safe
  43. _weapons = getWeaponCargo _safe;
  44. _magazines = getMagazineCargo _safe;
  45. _backpacks = getBackpackCargo _safe;
  46.  
  47. // Remove old safe from database
  48. PVDZE_obj_Delete = [_safeID,_safeUID,_activatingPlayer];
  49. publicVariableServer "PVDZE_obj_Delete";
  50.  
  51. // Delete original
  52. deleteVehicle _safe;
  53.  
  54. _storage = createVehicle ["VaultStorageLocked", _pos, [], 0, "CAN_COLLIDE"];
  55. _storage setdir _dir;
  56. _storage setpos _pos;
  57. _storage setVariable["CharacterID",_combination,true];
  58. _storage setVariable["ObjectID",_safeID,true];
  59. _storage setVariable["ObjectUID",_safeUID,true];
  60. _storage setVariable ["OEMPos", _pos, true];
  61.  
  62. //Add Items into newly coded safe
  63. if (count _weapons > 0) then {
  64. //Add weapons
  65. _objWpnTypes = _weapons select 0;
  66. _objWpnQty = _weapons select 1;
  67. _countr = 0;
  68. {
  69. _storage addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
  70. _countr = _countr + 1;
  71. } forEach _objWpnTypes;
  72. };
  73.  
  74. if (count _magazines > 0) then {
  75. //Add Magazines
  76. _objWpnTypes = _magazines select 0;
  77. _objWpnQty = _magazines select 1;
  78. _countr = 0;
  79. {
  80. _storage addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
  81. _countr = _countr + 1;
  82. } forEach _objWpnTypes;
  83. };
  84.  
  85. if (count _backpacks > 0) then {
  86. //Add Backpacks
  87. _objWpnTypes = _backpacks select 0;
  88. _objWpnQty = _backpacks select 1;
  89. _countr = 0;
  90. {
  91. _storage addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
  92. _countr = _countr + 1;
  93. } forEach _objWpnTypes;
  94. };
  95.  
  96. //Send Safe with new code to database and report code to player
  97. PVDZE_obj_Publish = [_combination,_storage,[_dir,_pos],_classname];
  98. publicVariableServer "PVDZE_obj_Publish";
  99. //force vault save just before locking
  100. PVDZE_veh_Update = [_storage,"gear"];
  101. publicVariableServer "PVDZE_veh_Update";
  102. hint format["New %1 code is: %2.",_text,_combination];
  103.  
  104. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement