Jump to content
  • 0

Safe Manager help


SmokeyBR

Question

ive been trying for the last couple of days adding a safe manager but i cannot make it pass the right format to the database hitpoints field.

the files were based on plotmanagement heres the revelant parts

Spoiler

//vaultaddfriends.sqf
private ["_vaults","_inList","_toAdd","_thevault","_friends","_friendUID","_friendName","_userList"];
disableSerialization;

_userList = (findDisplay 711198) displayCtrl 7011;

_friendUID = _this select 0;
_friendName = _userList lbText (lbCurSel _userList);

if (_friendUID == "") exitWith {};

_vaults = nearestObjects [[player] call FNC_getPos, [DZE_LockedStorage],15];

_thevault = _vaults select 0;
_friends = _thevault getVariable ["vaultFriends",[]];
_toAdd = [_friendUID,toArray _friendName];
_inList = false;

{ if ((_x  select 0) == (_toAdd select 0)) exitWith { _inList = true; }; } count _friends;
if (_inList) exitWith { systemChat localize "STR_EPOCH_PLOTMANAGEMENT_ADDFRIEND_ALREADYONTHELIST"; };
if ((count _friends) == DZE_Max_thevaultFriends) exitWith { systemChat format[localize "STR_EPOCH_PLOTMANAGEMENT_ADDFRIEND_FRIENDLIMIT", DZE_Max_thevaultFriends]; };

_friends set [(count _friends), _toAdd];
_thevault setVariable ["vaultFriends", _friends, true];

PVDZ_veh_Save = [_thevault,"damage"];
publicVariableServer "PVDZ_veh_Save";

call PlotGetFriends;
call PlotNearbyHumans;

 

server_monitor.sqf

Spoiler

			if( (count _inventory > 0) && !_isPlot && !_doorLocked) then {
				if (_type in DZE_LockedStorage) then {
					// Do not send big arrays over network! Only server needs these
					_object setVariable ["WeaponCargo",(_inventory select 0),false];
					_object setVariable ["MagazineCargo",(_inventory select 1),false];
					_object setVariable ["BackpackCargo",(_inventory select 2),false];
					_object setVariable ["vaultFriends", _hitPoints, true];
				} else {
					_weaponcargo = _inventory select 0 select 0;
					_magcargo = _inventory select 1 select 0;
					_backpackcargo = _inventory select 2 select 0;
				   _weaponqty = _inventory select 0 select 1;
					{_object addWeaponCargoGlobal [_x, _weaponqty select _foreachindex];} foreach _weaponcargo;

					_magqty = _inventory select 1 select 1;
					{_object addMagazineCargoGlobal [_x, _magqty select _foreachindex];} foreach _magcargo;

					_backpackqty = _inventory select 2 select 1;
					{_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
				};
			} else {
				if (DZE_permanentPlot && _isPlot) then {
					_object setVariable ["plotfriends", _inventory, true];
				};
				if (DZE_doorManagement && _doorLocked) then {
					_object setVariable ["doorfriends", _inventory, true];
				};
				if (_vault) then {
					_object setVariable ["vaultFriends", _hitPoints, true];
				};
			};
		};

 

server_updateObject.sqf

Spoiler

_object_damage = {
	//Allow dmg process
	private ["_hitpoints","_array","_hit","_selection","_key","_damage","_allFixed"];
		if ((typeOf (_object) in DZE_LockedStorage)) then {
			_damage = damage _object;
			_array = _object getVariable ["vaultFriends",[]];
			_allFixed = false;		
		};
	} else {
	_hitpoints = _object call vehicle_getHitpoints;
	_damage = damage _object;
	_array = [];
	_allFixed = true;
	
	{
		_hit = [_object,_x] call object_getHit;
		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
		if (_hit > 0) then {
			_allFixed = false;
			_array set [count _array,[_selection,_hit]];
			//diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit]; 
		} else {
			_array set [count _array,[_selection,0]]; 
		};
	} forEach _hitpoints;
	};
	
	if (_allFixed && !_totalDmg) then {_object setDamage 0;};
	
	if (_forced) then {        
		if (_object in needUpdate_objects) then {needUpdate_objects = needUpdate_objects - [_object];};
		_recorddmg = true;	       
	} else {
		//Prevent damage events for the first 10 seconds of the servers live.
		if (diag_ticktime - _lastUpdate > 10) then {
			if !(_object in needUpdate_objects) then {
				//diag_log format["DEBUG: Monitoring: %1",_object];
				needUpdate_objects set [count needUpdate_objects, _object];
				_recorddmg = true;
			};
		};
	};
	
	if (_recorddmg) then {
		if (_objectID == "0") then {
			_key = format["CHILD:306:%1:",_objectUID] + str _array + ":" + str _damage + ":";
		} else {
			_key = format["CHILD:306:%1:",_objectID] + str _array + ":" + str _damage + ":";
		};
		#ifdef OBJECT_DEBUG
		diag_log ("HIVE: WRITE: "+ str(_key));
		#endif
		
		_key call server_hiveWrite;   
	};
};

 

 

Right now the value im getting into Hitpoints field is [["76561197963145366",[83,109,111,107,101,121]]]

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
9 hours ago, SmokeyBR said:

ive been trying for the last couple of days adding a safe manager but i cannot make it pass the right format to the database hitpoints field.

the files were based on plotmanagement heres the revelant parts

  Hide contents


//vaultaddfriends.sqf
private ["_vaults","_inList","_toAdd","_thevault","_friends","_friendUID","_friendName","_userList"];
disableSerialization;

_userList = (findDisplay 711198) displayCtrl 7011;

_friendUID = _this select 0;
_friendName = _userList lbText (lbCurSel _userList);

if (_friendUID == "") exitWith {};

_vaults = nearestObjects [[player] call FNC_getPos, [DZE_LockedStorage],15];

_thevault = _vaults select 0;
_friends = _thevault getVariable ["vaultFriends",[]];
_toAdd = [_friendUID,toArray _friendName];
_inList = false;

{ if ((_x  select 0) == (_toAdd select 0)) exitWith { _inList = true; }; } count _friends;
if (_inList) exitWith { systemChat localize "STR_EPOCH_PLOTMANAGEMENT_ADDFRIEND_ALREADYONTHELIST"; };
if ((count _friends) == DZE_Max_thevaultFriends) exitWith { systemChat format[localize "STR_EPOCH_PLOTMANAGEMENT_ADDFRIEND_FRIENDLIMIT", DZE_Max_thevaultFriends]; };

_friends set [(count _friends), _toAdd];
_thevault setVariable ["vaultFriends", _friends, true];

PVDZ_veh_Save = [_thevault,"damage"];
publicVariableServer "PVDZ_veh_Save";

call PlotGetFriends;
call PlotNearbyHumans;

 

server_monitor.sqf

  Hide contents


			if( (count _inventory > 0) && !_isPlot && !_doorLocked) then {
				if (_type in DZE_LockedStorage) then {
					// Do not send big arrays over network! Only server needs these
					_object setVariable ["WeaponCargo",(_inventory select 0),false];
					_object setVariable ["MagazineCargo",(_inventory select 1),false];
					_object setVariable ["BackpackCargo",(_inventory select 2),false];
					_object setVariable ["vaultFriends", _hitPoints, true];
				} else {
					_weaponcargo = _inventory select 0 select 0;
					_magcargo = _inventory select 1 select 0;
					_backpackcargo = _inventory select 2 select 0;
				   _weaponqty = _inventory select 0 select 1;
					{_object addWeaponCargoGlobal [_x, _weaponqty select _foreachindex];} foreach _weaponcargo;

					_magqty = _inventory select 1 select 1;
					{_object addMagazineCargoGlobal [_x, _magqty select _foreachindex];} foreach _magcargo;

					_backpackqty = _inventory select 2 select 1;
					{_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
				};
			} else {
				if (DZE_permanentPlot && _isPlot) then {
					_object setVariable ["plotfriends", _inventory, true];
				};
				if (DZE_doorManagement && _doorLocked) then {
					_object setVariable ["doorfriends", _inventory, true];
				};
				if (_vault) then {
					_object setVariable ["vaultFriends", _hitPoints, true];
				};
			};
		};

 

server_updateObject.sqf

  Hide contents


_object_damage = {
	//Allow dmg process
	private ["_hitpoints","_array","_hit","_selection","_key","_damage","_allFixed"];
		if ((typeOf (_object) in DZE_LockedStorage)) then {
			_damage = damage _object;
			_array = _object getVariable ["vaultFriends",[]];
			_allFixed = false;		
		};
	} else {
	_hitpoints = _object call vehicle_getHitpoints;
	_damage = damage _object;
	_array = [];
	_allFixed = true;
	
	{
		_hit = [_object,_x] call object_getHit;
		_selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
		if (_hit > 0) then {
			_allFixed = false;
			_array set [count _array,[_selection,_hit]];
			//diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit]; 
		} else {
			_array set [count _array,[_selection,0]]; 
		};
	} forEach _hitpoints;
	};
	
	if (_allFixed && !_totalDmg) then {_object setDamage 0;};
	
	if (_forced) then {        
		if (_object in needUpdate_objects) then {needUpdate_objects = needUpdate_objects - [_object];};
		_recorddmg = true;	       
	} else {
		//Prevent damage events for the first 10 seconds of the servers live.
		if (diag_ticktime - _lastUpdate > 10) then {
			if !(_object in needUpdate_objects) then {
				//diag_log format["DEBUG: Monitoring: %1",_object];
				needUpdate_objects set [count needUpdate_objects, _object];
				_recorddmg = true;
			};
		};
	};
	
	if (_recorddmg) then {
		if (_objectID == "0") then {
			_key = format["CHILD:306:%1:",_objectUID] + str _array + ":" + str _damage + ":";
		} else {
			_key = format["CHILD:306:%1:",_objectID] + str _array + ":" + str _damage + ":";
		};
		#ifdef OBJECT_DEBUG
		diag_log ("HIVE: WRITE: "+ str(_key));
		#endif
		
		_key call server_hiveWrite;   
	};
};

 

 

Right now the value im getting into Hitpoints field is [["76561197963145366",[83,109,111,107,101,121]]]

I have not used this mod but that is  the correct value for a UID and a name that has been converted to an array (like how plot/door management do it)

Link to comment
Share on other sites

  • 0
On 8.04.2017 at 0:49 AM, salival said:

I have not used this mod but that is  the correct value for a UID and a name that has been converted to an array (like how plot/door management do it)

i tried install it but

Spoiler

if (_vault) then {

_object setVariable ["vau>

20:23:02   Error position: <_vault) then {

_object setVariable ["vau>

20:23:02   Error Undefined variable in expression: _vault

20:23:02 File z\addons\dayz_server\system\server_monitor.sqf, line 268

20:23:02 Error in expression <doorfriends", _inventory, true];

};

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...