Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- player_changeCode.sqf
- Meowzors change code script version 0.8
- 4-13-2014
- Usage: [_safe, _newCode] spawn player_changeCode;
- */
- DZE_ActionInProgress = true;
- _activatingPlayer = player;
- _safe = _this select 0;
- _classname = getText (configFile >> "CfgMagazines" >> _safe >> "ItemActions" >> "Build" >> "create");
- _text = getText (configFile >> "CfgVehicles" >> (typeOf _safe) >> "displayName");
- //Grab _newCode array and break apart
- _newCode = _this select 1;
- _combination_1 = _newCode select 0;
- _combination_2 = _newCode select 1;
- _combination_3 = _newCode select 2;
- // Format Combination
- _combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3];
- //If object is a safe instead of a lockbox we need one more number...
- if ((typeOf _classname) == "VaultStorage") then {
- {
- _combination_4 = _newCode select 3;
- _combination = format["%1%2",_combination,_combination_4,];
- };
- //Get variables from current safe
- _safeID = _safe getVariable["ObjectID","0"];
- _safeUID = _safe getVariable["ObjectUID","0"];
- //Get Location from current safe
- _dir = direction _safe;
- _pos = _safe getVariable["OEMPos",(getposATL _safe)];
- //FOR SOME REASON THIS DOES NOT GET DISPLAYED... Probably part of our problem...
- hint format["ID = %1 UID = %2 DIR = %3 POS = %4 Classname = %5.",_safeID,_safeUID,_dir,_pos, _classname];
- //Get cargo from safe
- _weapons = getWeaponCargo _safe;
- _magazines = getMagazineCargo _safe;
- _backpacks = getBackpackCargo _safe;
- // Remove old safe from database
- PVDZE_obj_Delete = [_safeID,_safeUID,_activatingPlayer];
- publicVariableServer "PVDZE_obj_Delete";
- // Delete original
- deleteVehicle _safe;
- _storage = createVehicle ["VaultStorageLocked", _pos, [], 0, "CAN_COLLIDE"];
- _storage setdir _dir;
- _storage setpos _pos;
- _storage setVariable["CharacterID",_combination,true];
- _storage setVariable["ObjectID",_safeID,true];
- _storage setVariable["ObjectUID",_safeUID,true];
- _storage setVariable ["OEMPos", _pos, true];
- //Add Items into newly coded safe
- if (count _weapons > 0) then {
- //Add weapons
- _objWpnTypes = _weapons select 0;
- _objWpnQty = _weapons select 1;
- _countr = 0;
- {
- _storage addweaponcargoGlobal [_x,(_objWpnQty select _countr)];
- _countr = _countr + 1;
- } forEach _objWpnTypes;
- };
- if (count _magazines > 0) then {
- //Add Magazines
- _objWpnTypes = _magazines select 0;
- _objWpnQty = _magazines select 1;
- _countr = 0;
- {
- _storage addmagazinecargoGlobal [_x,(_objWpnQty select _countr)];
- _countr = _countr + 1;
- } forEach _objWpnTypes;
- };
- if (count _backpacks > 0) then {
- //Add Backpacks
- _objWpnTypes = _backpacks select 0;
- _objWpnQty = _backpacks select 1;
- _countr = 0;
- {
- _storage addbackpackcargoGlobal [_x,(_objWpnQty select _countr)];
- _countr = _countr + 1;
- } forEach _objWpnTypes;
- };
- //Send Safe with new code to database and report code to player
- PVDZE_obj_Publish = [_combination,_storage,[_dir,_pos],_classname];
- publicVariableServer "PVDZE_obj_Publish";
- //force vault save just before locking
- PVDZE_veh_Update = [_storage,"gear"];
- publicVariableServer "PVDZE_veh_Update";
- hint format["New %1 code is: %2.",_text,_combination];
- DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement