Jump to content
  • 0

virtual garage


GudrunGisela

Question

Hi everyone,

 

I've got a problem with merging two files. I try to install the virtual garage script from 0verHeaT. His script requires Plot4Life to work. You can only open the Garage Menu if you are the owner of the related Plot Pole.I don't use Plot 4 Life but I use Plot Management and I'm asking me if it's possible to use the Plot Friends as opposed to the owner.

 

This is the fn_selfAction.sqf from the script:

 

private ["_garageowner","_garagefriends","_garageallowed","_friend"];
      _garageowner = _cursorTarget getVariable ["ownerPUID","010"]; //<-- We get the PUID of the owner. Here with P4L
      _friend = _cursorTarget getVariable ["GarageFriends",[]];
      _garagefriends = [];
      {
          _garagefriends set [count _garagefriends,(_x select 0)];
      } count _friend;
      _garageallowed = [_owner] + _garagefriends;
      if ((_typeOfCursorTarget in DZE_Garage) && (speed player <= 1) && _canDo) then {
          if (s_player_garage < 0) then {
              if ((getPlayerUID player) in _garageallowed) then {
                  s_player_garage =  player addAction ["<t color='#FFAA00'>Garage Menu</t>", "Garage\player_virtualgarage.sqf", _cursorTarget, 2, false];
              } else {
                  s_player_garage = player addAction ["<t color=#FF0000'>Garage Locked</t>", "",_cursorTarget, 2, true, true, "", "];    
              };
          };
      } else {
          player removeAction s_player_garage;
          s_player_garage = -1;        
      };

 

I'd be very happy if anyone could modify that for me :)

 

Best regards,

 

GudrunGisela

Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0

ok, my fault :D

 

This is an example how Plot Management allows the people to remove something:

 

///Allow owners to delete modulars
                if(_isModular) then {
                if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then {
                _findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0];
                _IsNearPlot = count (_findNearestPoles);
                _fuid  = [];
                _allowed = [];
                if(_IsNearPlot > 0)then{
                    _thePlot = _findNearestPoles select 0;
                    _owner =  _thePlot getVariable ["ownerPUID","010"];
                    _friends = _thePlot getVariable ["plotfriends", []];
                    {
                      _friendUID = _x select 0;
                      _fuid  =  _fuid  + [_friendUID];
                    } forEach _friends;
                    _allowed = [_owner];    
                    _allowed = [_owner] +  _fuid;    
                    if ( _playerUID in _allowed && _ownerID in _allowed ) then {  // // If u want that the object also belongs to someone on the plotpole.
                        _player_deleteBuild = true;
                    };                    
                    }else{
                    if(_ownerID == _playerUID)then{
                        _player_deleteBuild = true;
                    };
                };                                          
            };
        };

 

So my idea was to take some passages out of this to modify the code from the virtual garage so that the the plot friends are allowed people to open the garage menu.

Link to comment
Share on other sites

  • 0

Oh hi 0verHeaT :D,

 

thanks for your answer. No I don't use P4L. I've installed Plot Management with the Non Plot 4 Life Version. I tried to implement your script but if someone try to get the garage menu it says: garage locked. So I think that the owner is not recognized by the script. Do you have an alternative for me?

 

Best regards,

 

GudrunGisela

Link to comment
Share on other sites

  • 0

Yea this just refers on how to get the action.

You can try this out. This will let you access the garage if you are within your plot area and be the owner or friend of the plot.

However, if there is not any plot pole in range, you will not get any option. 

 

private ["_nearestPoles","_pole","_garagefriends","_garageallowed","_friends"];
_nearestPoles = nearestObjects [(vehicle player),["Plastic_Pole_EP1_DZ"],(DZE_PlotPole select 0)];
if (count _nearestPoles > 0) then
{
	_pole = _nearestPoles select 0;
	_friends = _pole getVariable ["plotfriends",[]];
	_owner = _pole getVariable ["ownerPUID","0"];
	_garagefriends = [];
	{
		_garagefriends set [_forEachIndex,(_x select 0)];
	} forEach _friends;
	_garageallowed = _garagefriends + [_owner];
	
	if ((_typeOfCursorTarget in DZE_Garage) && (speed player <= 1) && _canDo) then 
	{
		if (s_player_garage < 0) then 
		{
			if ((getPlayerUID player) in _garageallowed) then 
			{
				s_player_garage =  player addAction ["<t color='#FFAA00'>Garage Menu</t>","Garage\player_virtualgarage.sqf",_cursorTarget,2,false];
			} 
			else 
			{
				s_player_garage = player addAction ["<t color='#FF0000'>Garage Locked</t>","",_cursorTarget,2,true,true,"",""];    
			};
		};
	} 
	else 
	{
		player removeAction s_player_garage;
		s_player_garage = -1;        
	};
}
else
{
	player removeAction s_player_garage;
	s_player_garage = -1;   
}; 

Link to comment
Share on other sites

  • 0

I have Plot Management, Door Management, and 0verheat vehicle garage installed without plot 4 life.  Everything works perfectly for me but other players report the garage menu showing then disappearing when trying to access it.  I don't know if it is an admin thing or not.  Does anyone know what would cause the menu to show then disappear for normal players?

Link to comment
Share on other sites

  • 0

Sounds like an Antihack Problem to me. Do you use Infistar or similar 3rd Party AH Software? If so you need to whitelist the selfaction functions (s_player_garage) and the dialog function (50003,50004) in the AHconfig.sqf, I would guess.

Link to comment
Share on other sites

  • 0

Sounds like an Antihack Problem to me. Do you use Infistar or similar 3rd Party AH Software? If so you need to whitelist the selfaction functions (s_player_garage) and the dialog function (50003,50004) in the AHconfig.sqf, I would guess.

 

Thanks Copper.  I thought i had those added.

Link to comment
Share on other sites

  • 0

Not sure if anyone can help me or not, but I have everything working 100% only issue is after server restart it does not pull the owner or friends. I am doing this with plot management using the suggested script above by OverHeaT.

Basically after the server restarts I have to remove the plot pole and replace, then add myself as a friend on the plot pole in order to unlock the garage and access it. The plot pole still sees me as the owner, but I can only move friends after removing and replacing.

I have some basic scripting knowledge, but I am not even sure where to start troubleshooting this. There are no RTP errors and like I said it works 100% other then that little issue. Everything saves to the database as it should, menu comes up fine...... If anyone has any thoughts it would be helpful.

Ok Figured it out or at least found a work around. Just didn't edit the player_upgrade.sqf. now the garage uses the plot pole to get the friends and the manage part for the garage is useless, but it works :)

Thanks in advance.

Edited by azzdayz
Link to comment
Share on other sites

  • 0
On 12/05/2015 at 6:07 PM, GudrunGisela said:

For this script you don't need extDB. I'm using the script from 0verHeaT. This is the link: https://github.com/0verHeaT/VehicleGarage

 

By the way i found a solution to fix my problem. There was a missing line in server_updateobject.sqf. Now vehicles are saving to database.

 

365 days later

 

having a similar problem

 

apparently _garagelist is undefined this is puzzling me someone please assist

 

Quote

 4:46:17 Error in expression <{
_key = format["CHILD:309:%1:%2:",_uid,_garagelist];
} else {
_key = format["CH>
 4:46:17   Error position: <_garagelist];
} else {
_key = format["CH>
 4:46:17   Error Undefined variable in expression: _garagelist

 

here's the section server_updateobject

 

Quote

_object_inventory = {

     private["_inventory","_previous","_key"];
            _isNormal = true;
      if (typeOf (_object) == "Plastic_Pole_EP1_DZ") then{
             _isNormal = false;
          _inventory = _object getVariable ["plotfriends", []]; //We're replacing the inventory with UIDs for this item
    };
      if (typeOf (_object)in DZE_DoorsLocked) then{
               _isNormal = false;
           _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item
    };
     if ((typeOf _object) in DZE_Garage) then {
           _isNormal = false;
          if (isNil "_garagelist") then {
          _garagelist = _object getVariable ["StoredVehicles",[]];
  };
         if (_objectID == "0") then {
          _key = format["CHILD:309:%1:%2:",_uid,_garagelist];
          } else {
          _key = format["CHILD:303:%1:%2:",_objectID,_garagelist];
      };
_key call server_hiveWrite;
};
if(_isNormal)then {
_inventory = [
getWeaponCargo _object,
getMagazineCargo _object,
getBackpackCargo _object,
 _object getVariable["bankMoney",0]
];
_previous = str(_object getVariable["lastInventory",[]]);
if (str(_inventory) != _previous) then {
      _object setVariable["lastInventory",_inventory];
if (_objectID == "0") then {
     _key = format["CHILD:309:%1:%2:",_uid,_inventory];
      } else {
    _key = format["CHILD:303:%1:%2:",_objectID,_inventory];
   };
     //diag_log ("HIVE: WRITE: "+ str(_key));
       _key call server_hiveWrite;
     };
  };
};

 

Thanks in advanced 

 

Speedy

Link to comment
Share on other sites

  • 0
On 12/5/2016 at 4:50 AM, Pro_Speedy said:

 

365 days later

 

having a similar problem

 

apparently _garagelist is undefined this is puzzling me someone please assist

 

 

here's the section server_updateobject

 

 

Thanks in advanced 

 

Speedy

in server_updateObject.sqf line 2:

private ["_object","_type","_objectID",...];

add : ,"_garagelist"

 

Link to comment
Share on other sites

  • 0
In my case, when I planted the garage tells me this locked.
Use Plot For Life v2.5 With Snap Pro v1.4.1 & 1.0.4 Precise Base Building .
after comparing the two files server_updateObjects.sqf this is the result :
Quote

/*
[_object,_type] spawn server_updateObject;
*/
private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable","_garagelist"];

_object =     _this select 0;

if(isNull(_object)) exitWith {
    diag_log format["Skipping Null Object: %1", _object];
};

if ((typeOf _object) in DZE_Garage) then {_garagelist = _this select 2;};
_type =     _this select 1;
_parachuteWest = ((typeOf _object == "ParachuteWest") || (typeOf _object == "ParachuteC"));
_isbuildable = (typeOf _object) in dayz_allowedObjects;
_isNotOk = false;
_firstTime = false;

_objectID =    _object getVariable ["ObjectID","0"];
_uid =         _object getVariable ["ObjectUID","0"];

if ((typeName _objectID != "string") || (typeName _uid != "string")) then

    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
    //force fail
    _objectID = "0";
    _uid = "0";
};
if (!_parachuteWest && !(locked _object)) then {
    if (_objectID == "0" && _uid == "0") then
    {
        _object_position = getPosATL _object;
        _isNotOk = true;
    };
};

// do not update if buildable && not ok
if (_isNotOk && _isbuildable) exitWith {  };

// delete if still not ok
if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };


_lastUpdate = _object getVariable ["lastUpdate",time];
_needUpdate = _object in needUpdate_objects;

// TODO ----------------------
_object_position = {
    private["_position","_worldspace","_fuel","_key","_colour","_colour2"];
        _position = getPosATL _object;
if (_object isKindOf "AllVehicles") then {
        _colour = _object getVariable ["Colour","0"];
        _colour2 = _object getVariable ["Colour2","0"];
        _worldspace = [
            round(direction _object),
            _position,
            _colour,
            _colour2
        ];
        _fuel = fuel _object;
    } else {
        _worldspace = [(getDir _object) call KK_fnc_floatToString,    _position call KK_fnc_positionToString];
        ];
        _fuel = 0;
        _key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
        //diag_log ("HIVE: WRITE: "+ str(_key));
        _key call server_hiveWrite;
};

_object_inventory = {
    private["_inventory","_previous","_key"];
    if ((typeOf _object) in DZE_Garage) then {
            if (isNil "_garagelist") then {
                _garagelist = _object getVariable ["StoredVehicles",[]];
            };
            if (_objectID == "0") then {
                _key = format["CHILD:309:%1:%2:",_uid,_garagelist];
            } else {
                _key = format["CHILD:303:%1:%2:",_objectID,_garagelist];
            };

            _key call server_hiveWrite;
        } else {
        _isNormal = true;
        if (typeOf (_object)in DZE_DoorsLocked) then{
        _isNormal = false;
        _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item
            };
        if(_isNormal)then {
        _inventory = [
            getWeaponCargo _object,
            getMagazineCargo _object,
            getBackpackCargo _object,
            _object getVariable["bankMoney",0]
            ];
            };
        _previous = str(_object getVariable["lastInventory",[]]);
        if (str(_inventory) != _previous) then {
            if(alive _object) then{
        _object setVariable["lastInventory",_inventory];
    };
            if (_objectID == "0") then {
                _key = format["CHILD:309:%1:%2:",_uid,_inventory];
            } else {
                _key = format["CHILD:303:%1:%2:",_objectID,_inventory];
            };
            //diag_log ("HIVE: WRITE: "+ str(_key));
            _key call server_hiveWrite;
};
        };
};

_object_damage = {
    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
        _hitpoints = _object call vehicle_getHitpoints;
        _damage = damage _object;
        _array = [];
        {
            _hit = [_object,_x] call object_getHit;
            _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
            if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
            _object setHit ["_selection", _hit];
        } count _hitpoints;
    
        _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
        //diag_log ("HIVE: WRITE: "+ str(_key));
        _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
    };

_object_killed = {
    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    if(_object isKindOf "AllVehicles") then{
        _object execVM "\z\addons\dayz_server\compile\server_crashLoot.sqf";
    };
    _hitpoints = _object call vehicle_getHitpoints;
    //_damage = damage _object;
    _damage = 1;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _hit = 1;
        _object setHit ["_selection", _hit];
    } count _hitpoints;
    
    if (_objectID == "0") then {
        _key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
    } else {
        _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    };
    //diag_log ("HIVE: WRITE: "+ str(_key));
    _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
    if ((count _this) > 2) then {
        _killer = _this select 2;
        _charID = _object getVariable ['CharacterID','0'];
        _objID     = _object getVariable['ObjectID','0'];
        _objUID    = _object getVariable['ObjectUID','0'];
        _worldSpace = getPosATL _object;
        if (getPlayerUID _killer != "") then {
            _name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
            diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6, Killer: %7 (UID: %8)", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace, _name, (getPlayerUID _killer)];
        } else {
            diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace];
        };
    };
};

_object_repair = {

    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    _hitpoints = _object call vehicle_getHitpoints;
    _damage = damage _object;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _object setHit ["_selection", _hit];
    } count _hitpoints;
    
    _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    //diag_log ("HIVE: WRITE: "+ str(_key));
    _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
};
_object_vehicleKey = {
    private ["_hit","_selection","_fuel","_gotcha","_retry","_vehicleID","_key","_result","_outcome","_player","_class","_newKey","_newKeyName","_oldVehicleID","_oldVehicleUID","_hitpoints","_damage","_array","_inventory","_vehicleUID","_position","_dir","_worldspace"];
    
    /* Setting up variables */
    _player = _this select 0;
    _class = _this select 1;
    _newKey = _this select 2;
    _newKeyName = _this select 3;
    _oldVehicleID = _this select 4;
    _oldVehicleUID = _this select 5;

    /* Get Damage of the Vehicle */
    _hitpoints = _object call vehicle_getHitpoints;
    _damage = damage _object;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _object setHit ["_selection", _hit];
    } forEach _hitpoints;
    
    /* Get the Fuel of the Vehicle */
    _fuel = 0;
    if (_object isKindOf "AllVehicles") then {
        _fuel = fuel _object;
    };
    
    /* Get the Inventory of the Vehicle */
    _inventory = [
        getWeaponCargo _object,
        getMagazineCargo _object,
        getBackpackCargo _object
    ];
    
    /* Get the position of the Vehicle */
    _position     = getPosASL _object;
    if !(surfaceIsWater _position) then {
        _position =  ASLToATL _position;
    };
    _dir         = getDir _object;
    _worldspace = [_dir,_position];

    /* Delete the current Database entry */
    [_oldVehicleID,_oldVehicleUID,_player] call server_deleteObj;
    sleep 1;
    
    /* Generate a new UID */
    _vehicleUID = _worldspace call dayz_objectUID3;

    /* Write the new Database entry and LOG the action*/
    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _newKey, _worldspace, _inventory, _array, _fuel,_vehicleUID];
    _key call server_hiveWrite;
    diag_log ("HIVE: WRITE: VEHICLE KEY CHANGER: "+ str(_key)); 
    diag_log format["HIVE: WRITE: VEHICLE KEY CHANGER: Vehicle:%1 NewKey:%2 BY %3(%4)", _object, _newKeyName, (name _player), (getPlayerUID _player)];

    /* Get the ObjectID of the entry in the Database */
    _retry = 0;
    _gotcha = false;
    while {!_gotcha && _retry < 10} do {
        sleep 1;
        
        /* Send the request */
        _key = format["CHILD:388:%1:",_vehicleUID];
        diag_log ("HIVE: READ: VEHICLE KEY CHANGER: "+ str(_key));
        _result = _key call server_hiveReadWrite;
        _outcome = _result select 0;
        
        /* We got a answer */
        if (_outcome == "PASS") then {
            _vehicleID = _result select 1;
            
            /* Compare with old ObjectID to check if it not was deleted yet */
            if (_oldVehicleID == _vehicleID) then {
                /* Not good lets give it another try */
                _gotcha = false;
                _retry = _retry + 1;
            } else {
                /* GOTCHA! */
                diag_log("CUSTOM: VEHICLE KEY CHANGER: Selected " + str(_vehicleID));
                _gotcha = true;
                _retry = 11;

                _object setVariable ["VKC_disabled", 1,true];
                _object setVariable ["VKC_claiming_disabled", 1,true];

                [_object] spawn {
                    private ["_veh"];
                    _veh = _this select 0;

                    sleep 30;
                    _veh setVariable ["VKC_disabled", 0,true];
                    _veh setVariable ["VKC_claiming_disabled", 0,true];
                };

                PVDZE_vkc_Success = true;
                (owner _player) publicVariableClient "PVDZE_vkc_Success";

                /* Lock the Vehicle */
                _object setVehicleLock "locked";
    
                /* Save the ObjectID and ObjectUID to the vehicles variable and make it public */
                _object setVariable ["ObjectID", _vehicleID, true];
                _object setVariable ["ObjectUID", _vehicleUID, true];
    
                /* Set the lastUpdate time to current */
                _object setVariable ["lastUpdate",time,true];
    
                /* Set the CharacterID to the new Key so we can access it! */
                _object setVariable ["CharacterID", _newKey, true];
    
                /* Some other variables you might need for disallow lift/tow/cargo locked Vehicles and such */
                /* Uncomment if you use this */
    
                /* R3F Arty and LOG block lift/tow/cargo locked vehicles*/
                _object setVariable ["R3F_LOG_disabled",true,true];

                /* =BTC= Logistic block lift locked vehicles*/
                _object setVariable ["BTC_Cannot_Lift",true,true];
            };
        } else {
            /* Something went wrong on the request give it another try */
            diag_log("CUSTOM: VEHICLE KEY CHANGER: trying again to get id for: " + str(_vehicleUID));
            _gotcha = false;
            _retry = _retry + 1;
        };
    };
};
// TODO ----------------------

_object setVariable ["lastUpdate",time,true];
switch (_type) do {
    case "all": {
        call _object_position;
        call _object_inventory;
        call _object_damage;
        };
    case "position": {
        if (!(_object in needUpdate_objects)) then {
            //diag_log format["DEBUG Position: Added to NeedUpdate=%1",_object];
            needUpdate_objects set [count needUpdate_objects, _object];
        };
    };
    case "gear": {
        call _object_inventory;
            };
    case "damage": {
        if ( (time - _lastUpdate) > 5) then {
            call _object_damage;
        } else {
            if (!(_object in needUpdate_objects)) then {
                //diag_log format["DEBUG Damage: Added to NeedUpdate=%1",_object];
                needUpdate_objects set [count needUpdate_objects, _object];
            };
        };
    };
    case "killed": {
        call _object_killed;
    };
    case "repair": {
        call _object_damage;
    };
    case "vehiclekey": {
        _activatingPlayer = _this select 2;
        _vehicleClassname = _this select 3;
        _toKey = _this select 4;
        _toKeyName = _this select 5;
        _vehicle_ID = _this select 6;
        _vehicle_UID = _this select 7;
        [_activatingPlayer, _vehicleClassname, _toKey, _toKeyName, _vehicle_ID, _vehicle_UID] call _object_vehicleKey;;
    };
};
 

and the server_updateObject.sqf before changes :

Quote

/*
[_object,_type] spawn server_updateObject;
*/
private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable"];

_object =     _this select 0;

if(isNull(_object)) exitWith {
    diag_log format["Skipping Null Object: %1", _object];
};

_type =     _this select 1;
_parachuteWest = ((typeOf _object == "ParachuteWest") || (typeOf _object == "ParachuteC"));
_isbuildable = (typeOf _object) in dayz_allowedObjects;
_isNotOk = false;
_firstTime = false;

_objectID =    _object getVariable ["ObjectID","0"];
_uid =         _object getVariable ["ObjectUID","0"];

if ((typeName _objectID != "string") || (typeName _uid != "string")) then

    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
    //force fail
    _objectID = "0";
    _uid = "0";
};
if (!_parachuteWest && !(locked _object)) then {
    if (_objectID == "0" && _uid == "0") then
    {
        _object_position = getPosATL _object;
        _isNotOk = true;
    };
};

// do not update if buildable && not ok
if (_isNotOk && _isbuildable) exitWith {  };

// delete if still not ok
if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };


_lastUpdate = _object getVariable ["lastUpdate",time];
_needUpdate = _object in needUpdate_objects;

// TODO ----------------------
_object_position = {
    private["_position","_worldspace","_fuel","_key"];
        _position = getPosATL _object;
        _worldspace = [(getDir _object) call KK_fnc_floatToString,    _position call KK_fnc_positionToString];
        _fuel = 0;
        if (_object isKindOf "AllVehicles") then {
            _fuel = fuel _object;
        };
        _key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
        //diag_log ("HIVE: WRITE: "+ str(_key));
        _key call server_hiveWrite;
};

_object_inventory = {
    private["_inventory","_previous","_key"];
        _isNormal = true;
        if (typeOf (_object)in DZE_DoorsLocked) then{
        _isNormal = false;
        _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item
            };
        if(_isNormal)then {
        _inventory = [
            getWeaponCargo _object,
            getMagazineCargo _object,
            getBackpackCargo _object,
            _object getVariable["bankMoney",0]
            ];
            };
        _previous = str(_object getVariable["lastInventory",[]]);
        if (str(_inventory) != _previous) then {
            if(alive _object) then{
        _object setVariable["lastInventory",_inventory];
    };
            if (_objectID == "0") then {
                _key = format["CHILD:309:%1:%2:",_uid,_inventory];
            } else {
                _key = format["CHILD:303:%1:%2:",_objectID,_inventory];
            };
            //diag_log ("HIVE: WRITE: "+ str(_key));
            _key call server_hiveWrite;
        };
};

_object_damage = {
    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
        _hitpoints = _object call vehicle_getHitpoints;
        _damage = damage _object;
        _array = [];
        {
            _hit = [_object,_x] call object_getHit;
            _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
            if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
            _object setHit ["_selection", _hit];
        } count _hitpoints;
    
        _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
        //diag_log ("HIVE: WRITE: "+ str(_key));
        _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
    };

_object_killed = {
    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    if(_object isKindOf "AllVehicles") then{
        _object execVM "\z\addons\dayz_server\compile\server_crashLoot.sqf";
    };
    _hitpoints = _object call vehicle_getHitpoints;
    //_damage = damage _object;
    _damage = 1;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _hit = 1;
        _object setHit ["_selection", _hit];
    } count _hitpoints;
    
    if (_objectID == "0") then {
        _key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
    } else {
        _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    };
    //diag_log ("HIVE: WRITE: "+ str(_key));
    _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
    if ((count _this) > 2) then {
        _killer = _this select 2;
        _charID = _object getVariable ['CharacterID','0'];
        _objID     = _object getVariable['ObjectID','0'];
        _objUID    = _object getVariable['ObjectUID','0'];
        _worldSpace = getPosATL _object;
        if (getPlayerUID _killer != "") then {
            _name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
            diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6, Killer: %7 (UID: %8)", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace, _name, (getPlayerUID _killer)];
        } else {
            diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace];
        };
    };
};

_object_repair = {

    private["_hitpoints","_array","_hit","_selection","_key","_damage"];
    _hitpoints = _object call vehicle_getHitpoints;
    _damage = damage _object;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _object setHit ["_selection", _hit];
    } count _hitpoints;
    
    _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
    //diag_log ("HIVE: WRITE: "+ str(_key));
    _key call server_hiveWrite;
    _object setVariable ["needUpdate",false,true];
};
_object_vehicleKey = {
    private ["_hit","_selection","_fuel","_gotcha","_retry","_vehicleID","_key","_result","_outcome","_player","_class","_newKey","_newKeyName","_oldVehicleID","_oldVehicleUID","_hitpoints","_damage","_array","_inventory","_vehicleUID","_position","_dir","_worldspace"];
    
    /* Setting up variables */
    _player = _this select 0;
    _class = _this select 1;
    _newKey = _this select 2;
    _newKeyName = _this select 3;
    _oldVehicleID = _this select 4;
    _oldVehicleUID = _this select 5;

    /* Get Damage of the Vehicle */
    _hitpoints = _object call vehicle_getHitpoints;
    _damage = damage _object;
    _array = [];
    {
        _hit = [_object,_x] call object_getHit;
        _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
        if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
        _object setHit ["_selection", _hit];
    } forEach _hitpoints;
    
    /* Get the Fuel of the Vehicle */
    _fuel = 0;
    if (_object isKindOf "AllVehicles") then {
        _fuel = fuel _object;
    };
    
    /* Get the Inventory of the Vehicle */
    _inventory = [
        getWeaponCargo _object,
        getMagazineCargo _object,
        getBackpackCargo _object
    ];
    
    /* Get the position of the Vehicle */
    _position     = getPosASL _object;
    if !(surfaceIsWater _position) then {
        _position =  ASLToATL _position;
    };
    _dir         = getDir _object;
    _worldspace = [_dir,_position];

    /* Delete the current Database entry */
    [_oldVehicleID,_oldVehicleUID,_player] call server_deleteObj;
    sleep 1;
    
    /* Generate a new UID */
    _vehicleUID = _worldspace call dayz_objectUID3;

    /* Write the new Database entry and LOG the action*/
    _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _newKey, _worldspace, _inventory, _array, _fuel,_vehicleUID];
    _key call server_hiveWrite;
    diag_log ("HIVE: WRITE: VEHICLE KEY CHANGER: "+ str(_key)); 
    diag_log format["HIVE: WRITE: VEHICLE KEY CHANGER: Vehicle:%1 NewKey:%2 BY %3(%4)", _object, _newKeyName, (name _player), (getPlayerUID _player)];

    /* Get the ObjectID of the entry in the Database */
    _retry = 0;
    _gotcha = false;
    while {!_gotcha && _retry < 10} do {
        sleep 1;
        
        /* Send the request */
        _key = format["CHILD:388:%1:",_vehicleUID];
        diag_log ("HIVE: READ: VEHICLE KEY CHANGER: "+ str(_key));
        _result = _key call server_hiveReadWrite;
        _outcome = _result select 0;
        
        /* We got a answer */
        if (_outcome == "PASS") then {
            _vehicleID = _result select 1;
            
            /* Compare with old ObjectID to check if it not was deleted yet */
            if (_oldVehicleID == _vehicleID) then {
                /* Not good lets give it another try */
                _gotcha = false;
                _retry = _retry + 1;
            } else {
                /* GOTCHA! */
                diag_log("CUSTOM: VEHICLE KEY CHANGER: Selected " + str(_vehicleID));
                _gotcha = true;
                _retry = 11;

                _object setVariable ["VKC_disabled", 1,true];
                _object setVariable ["VKC_claiming_disabled", 1,true];

                [_object] spawn {
                    private ["_veh"];
                    _veh = _this select 0;

                    sleep 30;
                    _veh setVariable ["VKC_disabled", 0,true];
                    _veh setVariable ["VKC_claiming_disabled", 0,true];
                };

                PVDZE_vkc_Success = true;
                (owner _player) publicVariableClient "PVDZE_vkc_Success";

                /* Lock the Vehicle */
                _object setVehicleLock "locked";
    
                /* Save the ObjectID and ObjectUID to the vehicles variable and make it public */
                _object setVariable ["ObjectID", _vehicleID, true];
                _object setVariable ["ObjectUID", _vehicleUID, true];
    
                /* Set the lastUpdate time to current */
                _object setVariable ["lastUpdate",time,true];
    
                /* Set the CharacterID to the new Key so we can access it! */
                _object setVariable ["CharacterID", _newKey, true];
    
                /* Some other variables you might need for disallow lift/tow/cargo locked Vehicles and such */
                /* Uncomment if you use this */
    
                /* R3F Arty and LOG block lift/tow/cargo locked vehicles*/
                _object setVariable ["R3F_LOG_disabled",true,true];

                /* =BTC= Logistic block lift locked vehicles*/
                _object setVariable ["BTC_Cannot_Lift",true,true];
            };
        } else {
            /* Something went wrong on the request give it another try */
            diag_log("CUSTOM: VEHICLE KEY CHANGER: trying again to get id for: " + str(_vehicleUID));
            _gotcha = false;
            _retry = _retry + 1;
        };
    };
};
// TODO ----------------------

_object setVariable ["lastUpdate",time,true];
switch (_type) do {
    case "all": {
        call _object_position;
        call _object_inventory;
        call _object_damage;
        };
    case "position": {
        if (!(_object in needUpdate_objects)) then {
            //diag_log format["DEBUG Position: Added to NeedUpdate=%1",_object];
            needUpdate_objects set [count needUpdate_objects, _object];
        };
    };
    case "gear": {
        call _object_inventory;
            };
    case "damage": {
        if ( (time - _lastUpdate) > 5) then {
            call _object_damage;
        } else {
            if (!(_object in needUpdate_objects)) then {
                //diag_log format["DEBUG Damage: Added to NeedUpdate=%1",_object];
                needUpdate_objects set [count needUpdate_objects, _object];
            };
        };
    };
    case "killed": {
        call _object_killed;
    };
    case "repair": {
        call _object_damage;
    };
    case "vehiclekey": {
        _activatingPlayer = _this select 2;
        _vehicleClassname = _this select 3;
        _toKey = _this select 4;
        _toKeyName = _this select 5;
        _vehicle_ID = _this select 6;
        _vehicle_UID = _this select 7;
        [_activatingPlayer, _vehicleClassname, _toKey, _toKeyName, _vehicle_ID, _vehicle_UID] call _object_vehicleKey;;
    };
};
 

no errors RPT

thanks in advanced

Link to comment
Share on other sites

  • 0

UPDATE: I've got it working where admins can add a user as "friend" to the infostand. Then that user can add / remove vehicles etc as normal.  Which is pretty much how I wanted it to work. So that's that , great , job done :D

-----

I would like to set this up so that an admin spawns in a "Infostand_2_EP1" and then changes the ObjectUID to the players UID.  Without having to use P4L or PlotFriends etc.. I don't want the user to have to place down a plot pole, I want the admin to have to manually add the Infostand_2_EP1 then edit the database.  If I use the self actions code provided on the github and change it like below, the admins can access the garages and save vehicles etc, but adding friends to the garage doesn't save after restart and the user who's UID has been added to the ObjectUID still doesn't get the manage option.. any ideas ?

20161015155213_1.jpg

fvhi5j.jpg

 

if ((_typeOfCursorTarget in DZE_Garage) && (speed player <= 1) && _canDo) then {
    private ["_garageowner","_garagefriends","_garageallowed","_friend"];
        _garageowner = _cursorTarget getVariable ["ObjectUID","0"]; //<-- We get the PUID of the owner. Here with P4L
        _friend = _cursorTarget getVariable ["GarageFriends",[]];
        _garagefriends = [];
{
    _garagefriends set [count _garagefriends,(_x select 0)];
} count _friend;
_garageallowed = [_garageowner] + _garagefriends + AdminAndModList;
	    if (s_player_garage < 0) then {
        if ((getPlayerUID player) in _garageallowed) then {
            s_player_garage =  player addAction ["<t color='#FFAA00'>Garage Menu</t>", "Garage\player_virtualgarage.sqf", _cursorTarget, 2, false];
        } else {
            s_player_garage = player addAction ["<t color='#FF0000'>Garage Locked</t>", "",_cursorTarget, 2, true, true, "", ""];   
        };
    };
} else {
    player removeAction s_player_garage;
    s_player_garage = -1;       
};
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...