Jump to content
Sign in to follow this  
1para{god-father}

Lock and unlock multiple things

Recommended Posts

Is there a way I can lock a lot of static weapons and vehicles then unlock them via my action menu?

But only allow 1 person in MP to so this i.e. squad leader name “M1†that way it is controlled.

Cheers

Share this post


Link to post
Share on other sites

Domination by Xeno has an admin option to do just that.

look into addAction, lock, cursortarget to combine them into a simplified version of what you want.

---------- Post added at 08:20 PM ---------- Previous post was at 06:44 PM ----------

worked up something working, should work in MP, untested MP, working SP.

There are ofc other examples out there, here is my go.

This locks all vehicle positions of any vehicle,air vehicle, static.

Can also make it lock only driver or gunner seats etc by modifyng the lock true line in lock.sqf with fex:

_vehicle lockDriver true;

If the vehicle is not locked for all players on server try removing

the lines

if (isServer) then { 

AND the lastline with

 };

from lock.sqf

either place both scripts in Demonized\lockVehicles\ inside your mission folder or edit lockaction.sqf to where you want them placed.

then place this line in init.sqf.

_null = [] execVM "Demonized\lockVehicles\lockaction.sqf";

lockaction.sqf

// action to lock unlock vehicles.
_janitor = M1;  // unit who has the magic keys.
waitUntil {M1 == player};
//_janitor = _this select 0;  // uncomment this line and delete the above one if you want to call janitor from [this] execVM "lockactions.sqf"
_range = 5;  // range of the magic keys.
while {true} do {
if (player != _janitor) exitWith {};
if ((vehicle _janitor) == _janitor) then {
	_vehicle = cursorTarget;
	if (_vehicle isKindOf "AllVehicles" AND !(_vehicle isKindOf "Man")) then {
		if ((_janitor distance _vehicle) <= _range) then {
			if (locked _vehicle) then {
				_unlockAct = _janitor addAction ["unlock vehicle","Demonized\lockVehicles\lock.sqf",[_vehicle, "unlock"]];
				waitUntil {_vehicle != cursorTarget OR !(locked _vehicle)};
				_janitor removeAction _unlockAct;
			} else {
				_lockAct = _janitor addAction ["lock vehicle","Demonized\lockVehicles\lock.sqf",[_vehicle, "lock"]];
				waitUntil {_vehicle != cursorTarget OR locked _vehicle};
				_janitor removeAction _lockAct;	
			};
		};
	};
	sleep 2;
	waitUntil {alive _janitor};
};
};

lock.sqf

// lock unlock actions.
_action = _this select 3;
_vehicle = _action select 0;
_mode = _action select 1;
_debugMode = true;

if (isServer) then {
if (_mode == "lock") then {
	_vehicle lock true;
	if (_debugMode) then {hint "vehicle is now locked"};
};
if (_mode == "unlock") then {
	_vehicle lock false;
	if (_debugMode) then {hint "vehicle is now unlocked"};
};
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×