Jump to content
Sign in to follow this  
cbale2000

Creating player-specific automatically opening gates

Recommended Posts

I'm trying to create a "Members Only" area on a mission I'm working on, and as part of it, I'm trying to make gates into this area that will automatically open for members but not everyone on the server.

I've already got the gates to automatically open when any user enters a trigger (per this thread), but I would like to set it up so that the gates will only open for players in some given list I create (and still open even if those players are in a vehicle). I would also like to be able to disable the action menu buttons on the gates ("open" and "close") so that random people can't just open them and get in.

Any ideas? So far my search for how to script this has come up empty. :(

EDIT:

Since posting this, I've gotten the gate triggers to open automatically for specific UIDs in a list using this command in the condition field of the trigger...

(vehicle player) in thislist and (getPlayerUID player in masterUIDArray)

...and creating a "masterUIDArray" in the init.sqf file. Unfortunately this method still allows other players to activate the gates using the action menu buttons, so I still need to find a way to disable them. I am also looking to find the name of the animation of this gate so I can trigger it to open and close.

Edited by cbale2000

Share this post


Link to post
Share on other sites

you are using a trigger to open the gate right?

if so, put the following code in the condition field:

this && ((vip1 in thisList) || (vip2 in thisList) || (vip3 in thisList))

just put on a list like this and replace "vip#" with the mane of the unit.

if you want to work by the player's UID then its a bit more complicated:

First, you need to get the UID of every player that would be able to open the gate.

Then, create a new sqf file and call it "UIDcheck.sqf" or something like that.

in it, put the following code:

Access = False;
_UIDlist = ["000000", "111111", "222222"]; //a list of all the UIDs of the vips.
_trigger = viptrig; //the trigger that activates the gates.

while {true} do {
{ 
waitUntil {(vehicle _x) in (list _trigger)};
_uid = getPlayerUID _x;
if (_uid in _UIDlist) then {
Access = True;
};
waitUntil {!((vehicle _x) in (list _trigger))};
Access = False;
sleep 1;
} forEach playableUnits;
sleep 1;
};

*put the UIDs you got from the vips instead of the numbers in the _UIDlist. make sure the "" stays! or it will not work!*

*you need to switch the "viptrig" with the name of the trigger that opens the gates*

in the condition field of the same trigger put "This && Access;".

checked it only on a local server, but it should work if there are many players as well.

and add the following line to your init.sqf:

[] execVM "UIDcheck.sqf";

Edited by Silderoy
addition

Share this post


Link to post
Share on other sites
you are using a trigger to open the gate right?

if so, put the following code in the condition field:

*Code snipped for to save space*

just put on a list like this and replace "vip#" with the mane of the unit.

if you want to work by the player's UID then its a bit more complicated:

First, you need to get the UID of every player that would be able to open the gate.

Then, create a new sqf file and call it "UIDcheck.sqf" or something like that.

in it, put the following code:

*Code snipped for to save space*

*put the UIDs you got from the vips instead of the numbers in the _UIDlist. make sure the "" stays! or it will not work!*

*you need to switch the "viptrig" with the name of the trigger that opens the gates*

in the condition field of the same trigger put "This && Access;".

checked it only on a local server, but it should work if there are many players as well.

and add the following line to your init.sqf:

*Code snipped for to save space*

Since I posted the thread (and waited for it to show up from moderator approval) I managed to get the player triggering to work. What I am currently using to open the gates (via the trigger area) is this in the condition field:

(vehicle player) in thislist and (getPlayerUID player in masterUIDArray)

I then have an array of all the UIDs in the init file. This method so far works well for getting the trigger to to activate for only players listed in that array. The problem I now have is preventing other players from just walking up to the gates and opening them using the action menu.

to disable default actions you need to overwrite classes in config.cpp

Is there perhaps a way to just limit the actions to specific players? Or perhaps you could elaborate on how to overwrite classes? I have no idea what I would be looking for in the config.cpp

On a different note, does anyone happen to know the animation commands to trigger this gate to open and close?

Share this post


Link to post
Share on other sites

you can make a anti action to the action, if that makes sense.

do it so

if (((_gate animationPhase "Bargate") < 0.9) && !((vehicle player) in thislist && (getPlayerUID player in masterUIDArray))) then {
_gate animate ["Bargate",1];
};

if the gate is opening, and none of the spesific players are in the trigger, then close it...

Share this post


Link to post
Share on other sites

Would that go in the trigger condition field or somewhere else?

Share this post


Link to post
Share on other sites
Would that go in the trigger condition field or somewhere else?

this code goes into a trigger.

create a new trigger, size and activation doesnt metter.

Cond:

((_gate animationPhase "Bargate") < 0.9) && !((vehicle player) in list _trigger && (getPlayerUID player in masterUIDArray)))

On Act:

_gate animate ["Bargate",1];

_gate is the name of the gate in the editor.

_trigger is the name of the trigger that opens the gate from the first post.

Share this post


Link to post
Share on other sites
this code goes into a trigger.

create a new trigger, size and activation doesnt metter.

Cond:

((_gate animationPhase "Bargate") < 0.9) && !((vehicle player) in list _trigger && (getPlayerUID player in masterUIDArray)))

On Act:

_gate animate ["Bargate",1];

_gate is the name of the gate in the editor.

_trigger is the name of the trigger that opens the gate from the first post.

I had to play around with it a bit, but I did get it to work in single player correctly (gates open if my UID is in the list, close if it is not). However, when I put it up on my server, the trigger that automatically opens the gates activates, but then for some reason the gate closes again right away (as if the anti action trigger was closing the gates for everyone). Not sure why its doing this on just the server. :confused:

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  

×