Jump to content
Sign in to follow this  
dmustanger

Unlocking a locked gate

Recommended Posts

Hi i am having problems unlocking a locked gate. The gate locks fine. Problem is i cant get the gate to unlock. I know for sure it is reading the uids as it is displaying the correct message to the players. Here is the code i am using, any suggestions?

I create a gate and name it gate1 and in the init field i have this

this addEventHandler ["HandleDamage",{}]; lock= [] execVM "lock.sqf"

lock.sqf contains this

Lock = true;
APlayers = ["123456", "123456"];
while {Lock} do
{
gate1 animate ["Door01",0];
sleep 0.1;
};

I then create a trigger over the gate and in the init field i have this

unlock = [] execVM "unlock.sqf"

unlock.sqf contains this

if (getPlayerUID player in APlayers) then
{
Lock = false;
gate1 animate ["Door01",1];
hint "Gate Unlocked!";
}
else
{
Lock = true;
gate1 animate ["Door01",0];
hint "Gate Is Locked!";
};

Share this post


Link to post
Share on other sites

What is the exact classname of the gate you are creating? Is it a double door gate? If I know this, I can tell you the correct command.

Most of the gates I have found which you can open and close use the following:

this animate ["Dvere1", 0];

this animate ["Dvere1", 1];

or for double door gates:

this animate ["Dvere1", 0];this animate ["Dvere2", 0];

this animate ["Dvere1", 1];this animate ["Dvere2", 1];

Although I have also found DoorL and DoorR. Is this a bar gate?

What triggers the trigger you have placed?

Edited by panther42

Share this post


Link to post
Share on other sites

it is a "Land_BarGate2".

I have it working for the most part now. its still a little buggy when there are more than 2 players on the trigger. but one at a time it works great.

here is what i have now

the gate

text="gate1";
init="this addEventHandler [""HandleDamage"",{}]; lock = execVM ""gate\lock.sqf""";

lock.sqf

while {isNil "gLock"} do
{
gate1 animate ["Door01",0];
sleep 0.1;
};

I place a trigger around the gate

a=15;
b=15;
activationBy="WEST";
repeating=1;
age="UNKNOWN";
expActiv="unlock = execVM ""gate\unlock.sqf""";
expDesactiv="relock = execVM ""gate\relock.sqf""";

unlock.sqf

if (isNil "gLock") then
{
_meters = player distance gate1;
if (_meters <= 15) then 
{
	_Players = ["123456","123456"];
	if (getPlayerUID player in _Players) then
	{
		gLock = false;
		publicVariable "gLock";
		gate1 animate ["Door01",1];
	};
};
};

relock.sqf

if (!isNil "gLock") then
{	
gLock = Nil;
publicVariable "gLock";
lock = execVM "gate\lock.sqf"
};

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  

×