Help lock any car near player

Darthmard

Member
I'm looking for script that will lock all vehicles in a 2m range of a player

this is what I did try no luck of it working :(

Code:
				if(player distance _vehicle < 2) then {
					DZE_ActionInProgress = true;
					s_player_lockUnlock_crtl = 1;

					PVDZE_veh_Lock = [_vehicle,true];
					if (local _vehicle) then {
						PVDZE_veh_Lock spawn local_lockUnlock
					} else {
						publicVariable "PVDZE_veh_Lock";
					};

					s_player_lockUnlock_crtl = -1;
					DZE_ActionInProgress = false;

				};
 
Is your above code within a loop that constantly checks if the player is nearby a vehicle and then assigns that nearby vehicle object to _vehicle?
https://community.bistudio.com/wiki/nearestObjects is what you would want to use

I am no rocket scientist when it comes to epoch but I dont know why you would have to fool with those epoch files. (maybe you DO, maybe you DONT, I really dont know for sure)
Why cant you just use
_vehicle setvehiclelock "locked";
https://community.bistudio.com/wiki/setVehicleLock
https://community.bistudio.com/wiki/lock
I assume the pvdze veh lock would propagate this data to all players.
Code:
    if(player distance _vehicle < 2) then {
                     _vehicle setvehiclelock "locked";
                    PVDZE_veh_Lock = [_vehicle,true];
                    if (local _vehicle) then {
                        PVDZE_veh_Lock spawn local_lockUnlock
                    } else {
                        publicVariable "PVDZE_veh_Lock";
                    };
   };
 
This is from admin tools for point to lock.
Code:
_obj = cursorTarget;
if(isNull _obj) exitWith {};
_objType = typeOf _obj;
_ownerID = _obj getVariable["ObjectID","0"];
_objectID = _obj getVariable["ObjectID","0"];

// Lock car
if (_obj isKindOf "LandVehicle" || _obj isKindOf "Air" || _obj isKindOf "Ship") then {
    {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = 1;

    PVDZE_veh_Lock = [_obj,true];

    if (local _obj) then {
        PVDZE_veh_Lock spawn local_lockUnlock
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
   
    s_player_lockUnlock_crtl = -1;
Maybe modify it so its:
Code:
_obj = player distance [0,0,2]
if(isNull _obj) exitWith {};
_objType = typeOf _obj;
_ownerID = _obj getVariable["ObjectID","0"];
_objectID = _obj getVariable["ObjectID","0"];

// Lock car
if (_obj isKindOf "LandVehicle") then {
    {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = 1;

    PVDZE_veh_Lock = [_obj,true];

    if (local _obj) then {
        PVDZE_veh_Lock spawn local_lockUnlock
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
   
    s_player_lockUnlock_crtl = -1;
note that I changed the - player distance [0,0,2]
 
Actually yes the better way would be:
Code:
_obj = nearestObjects [player, ["LandVehicle"], 2];
if(isNull _obj) exitWith {};
_objType = typeOf _obj;
_ownerID = _obj getVariable["ObjectID","0"];
_objectID = _obj getVariable["ObjectID","0"];

// Lock car
if (_obj isKindOf "LandVehicle") then {
    {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = 1;

    PVDZE_veh_Lock = [_obj,true];

    if (local _obj) then {
        PVDZE_veh_Lock spawn local_lockUnlock
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
   
    s_player_lockUnlock_crtl = -1;

Incidentally totally unrelated:
Code:
private ["_escMenu","_typf","_mxBckpcks"];

disableSerialization;
waitUntil {!isNull findDisplay 49};
_escMenu = findDisplay 49;
{
   _typf = typeOf cursortarget;
   _mxBckpcks = getNumber (configFile >> "CfgVehicles" >> _typf >> "transportmaxbackpacks");
   if (!(isNull _x) && (canbuild) && !(_x == player || typeOf _x in ["WeaponHolder","DebugBoxPlayer_DZ"]) && (_mxBckpcks > 0)) exitWith
   {
      titleText ["<Anti-Dupe>: You cannot log out near a storage unit!", "PLAIN DOWN", 3];
      systemchat "<Anti-Dupe>: You cannot log out near a storage unit!";
      _escMenu closedisplay 0;
   };
} foreach (nearestObjects [player, ["All"], 7.5]);
changed to:
Code:
private ["_escMenu","_typf","_mxBckpcks"];

disableSerialization;
waitUntil {!isNull findDisplay 49};
_escMenu = findDisplay 49;
{
   _typf = nearestObjects [player, ["WeaponHolder","DebugBoxPlayer_DZ"]], 2];
   _mxBckpcks = getNumber (configFile >> "CfgVehicles" >> _typf >> "transportmaxbackpacks");
   if (!(isNull _x) && (canbuild) && !(_x == player || typeOf _x in ["WeaponHolder","DebugBoxPlayer_DZ"]) && (_mxBckpcks > 0)) exitWith
   {
      titleText ["<Anti-Dupe>: You cannot log out near a storage unit!", "PLAIN DOWN", 3];
      systemchat "<Anti-Dupe>: You cannot log out near a storage unit!";
      _escMenu closedisplay 0;
   };
} foreach (nearestObjects [player, ["All"], 7.5]);
Players are simply getting around the dupe by looking away from the storage box, hense the cursortarget is void.
 
hmm did try both car is not locking in 2 or 5m range, to give you idea what I'm doing I'm making a car bomb script that will lock car after bomb is on it so far bomb stuff works but it's not locking cars

see this:
Code:
//edit by darthmard
private ["_mypos","_bombOwnerUID","_mags","_tool","_onLadder","canDo","_vehicle","_cursorTarget","_objects","_i","_ownerID","_objectID","_obj"];

_mags = magazines player;
_tool = items player;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);

    if (("ItemToolbox" in _tool) && ("HandGrenade_West" in _mags)) then {
        player playActionNow "Medic";
        
        _mypos = getPosATL player;
        _bombOwnerUID =  getPlayerUID player;
        
        sleep 5;
        
        player removeMagazine "HandGrenade_West";
        
        DZ_boobyTrap = [_bombOwnerUID,_myPos];
        publicVariableServer "DZ_boobyTrap"; //Send needed values to server.
        DZ_boobyTrap = []; //Clean up global variable.
   
//lock car    part start
_obj = nearestObjects [player, ["LandVehicle"], 2];
if(isNull _obj) exitWith {};
_objType = typeOf _obj;
_ownerID = _obj getVariable["ObjectID","0"];
_objectID = _obj getVariable["ObjectID","0"];

if (_obj isKindOf "LandVehicle") then {
    {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = 1;

    PVDZE_veh_Lock = [_obj,true];

    if (local _obj) then {
        PVDZE_veh_Lock spawn local_lockUnlock
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
  
    s_player_lockUnlock_crtl = -1;

        cutText [format["Trap is set!"], "PLAIN DOWN"];            

                 //end
       
    } else {
        cutText [format["You do not have the required material. You need a toolbox and a grenade."], "PLAIN DOWN"];
    };
 
I dont see anywhere that it is actually attaching to the vehicle. Use the attachTo then you can use the target to lock the vehicle that has the booby trap.
 
Try this:
Code:
//edit by darthmard
private ["_mypos","_bombOwnerUID","_mags","_tool","_onLadder","canDo","_vehicle","_cursorTarget","_objects","_i","_ownerID","_objectID","_obj"];

_mags = magazines player;
_tool = items player;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);

    if (("ItemToolbox" in _tool) && ("HandGrenade_West" in _mags)) then {
        player playActionNow "Medic";
       
        _mypos = getPosATL player;
        _bombOwnerUID =  getPlayerUID player;
       
        sleep 5;
       
        player removeMagazine "HandGrenade_West";
       
        DZ_boobyTrap = [_bombOwnerUID,_myPos];
        publicVariableServer "DZ_boobyTrap"; //Send needed values to server.
        DZ_boobyTrap = []; //Clean up global variable.
   
//lock car    part start
_obj = nearestObjects [player, ["LandVehicle"], 2];

if (_obj distance player <2) then { //////////////////////////////////////change was here
    {player removeAction _x} forEach s_player_lockunlock;s_player_lockunlock = [];
    s_player_lockUnlock_crtl = 1;

    PVDZE_veh_Lock = [_obj,true];

    if (local _obj) then {
        PVDZE_veh_Lock spawn local_lockUnlock
    } else {
        publicVariable "PVDZE_veh_Lock";
    };
    s_player_lockUnlock_crtl = -1;

        cutText [format["Trap is set!"], "PLAIN DOWN"];            

                 //end
       
    } else {
        cutText [format["You do not have the required material. You need a toolbox and a grenade."], "PLAIN DOWN"];
    };
 
after bit testing this works
Code:
_vehicle = _this select 3;
DZE_ActionInProgress = true;

{player removeAction _x} count s_player_lockunlock;s_player_lockunlock = [];
s_player_lockUnlock_crtl = 1;

PVDZE_veh_Lock = [_vehicle,true];
if(player distance _vehicle < 10) then {
	if (local _vehicle) then {
		PVDZE_veh_Lock spawn local_lockUnlock
	} else {
		publicVariable "PVDZE_veh_Lock";
	};
};

s_player_lockUnlock_crtl = -1;
DZE_ActionInProgress = false;
end up been default epoch code worked ok after all

thanks for help guys :)
 
So is the point to put a bomb in the car and then if its locked, nobody can remove it?
Or are we trying to lock players into a car that will explode? <<< I LIKE IT!
 
Back
Top