Home   Help Search Login Register  

Author Topic: Open/Close Gate  (Read 9281 times)

0 Members and 1 Guest are viewing this topic.

Offline R0adrunner

  • Members
  • *
Open/Close Gate
« on: 08 Feb 2007, 18:11:49 »
Is there anybody who know how too open/glose the "Bar Gate" in ArmA with a trigger?   ???

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #1 on: 08 Feb 2007, 20:12:29 »
Here ya go:

Code: [Select]
// Close gate
gate animate ["Bargate", 1];

// Open gate
gate animate ["Bargate", 0];

To open and close doors in a building the commands are similar, but 0 closes and 1 opens:

Code: [Select]
// Close Door 1
house animate ["Dvere1", 0];

// Open Door 1
house animate ["Dvere1", 1];

With building doors, I've only tried this with a building with only one door.  But I am assuming buildings with multiple doors would continue the naming pattern of Dvere1, Dvere2, Dvere3, etc.  "Dvere" is czech for "door" by the way...
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline R0adrunner

  • Members
  • *
Re: Open/Close Gate
« Reply #2 on: 08 Feb 2007, 21:57:07 »
Thanks Johnnyboy :good:

It works, but the animation is "laggy" :thumbsdown:

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #3 on: 09 Feb 2007, 00:47:24 »
Glad it worked for you.  You have to love the forums...I've been helped so many times, it feels good to give back.

I noticed it was choppy.  I'm guessing its not "lag" but just poorly animated (i.e., less frames), since I don't have a lag problem in general...
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline sharkattack

  • Former Staff
  • ****
Re: Open/Close Gate
« Reply #4 on: 21 Apr 2007, 10:27:31 »
how  do you open doors ?
ive been trying   position player nearestObject ***** animate ["Dvere1", 1]
but no luck  ... builings i tried on have had only one door ... am i calling it correctly   ???
"HOLY SARDINE" - see Shark-Attack meet his match

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Open/Close Gate
« Reply #5 on: 21 Apr 2007, 10:40:20 »
You can only open doors that are openeable.
You can see whether the door is such type by approaching it and if you get an action to open it, it's openeable..

EDIT:
Or if it already is openeable the chances are the selection name Dvere is no longer used in ArmA buildings..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline sharkattack

  • Former Staff
  • ****
Re: Open/Close Gate
« Reply #6 on: 21 Apr 2007, 10:48:34 »
ok mate ... thanx for clearing that up !    :good:
"HOLY SARDINE" - see Shark-Attack meet his match

Offline jose

  • Members
  • *
Re: Open/Close Gate
« Reply #7 on: 04 May 2007, 21:11:50 »
I can't get my bar gates working with those codes. Do you mean those stop sign gates which are usually on the entrance of the militarybase? ??? My ArmA version is 1.05.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #8 on: 05 May 2007, 01:42:08 »
Attached is a sample test mission.  It shows a bar gate opening and closing.

However, I believe the animation only works with gates placed via the object editor.

I believe that bar gates that are built in to the map are static, and have no animation.  I tried the following code on the built in map bar gates, and it did not work:

Code: [Select]
((position player) nearestObject 123) animate ["Bargate", 1];
123 would be the object ID of the bargate.

My Arma version is also 1.05.
« Last Edit: 05 May 2007, 01:49:49 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline genji

  • Members
  • *
Re: Open/Close Gate
« Reply #9 on: 15 May 2007, 23:24:49 »
thats a fine script that works perfect johnnyboy :good:

is there a way to have a trigger activate the script if any vehicle comes in range?

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #10 on: 15 May 2007, 23:57:11 »
Right now the trigger is set up to look for a single vehicle named "stryker":

Code: [Select]
this && stryker in thislist 
Having it open for any vehicle that happened by would probably require a script rather than a simple trigger condition.   Maybe set the trigger to Anybody Present and Repeatedly, and on activation it runs a script to checks all the units in thislist (i.e. all units in trigger) to see if any of the units is in a vehicle (i.e., vehicle unit not equal unit).  If so, then the script executes the bargate open command.

That should work. 
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline genji

  • Members
  • *
Re: Open/Close Gate
« Reply #11 on: 16 May 2007, 00:48:59 »
thanks johhnyboy for the quick reply

here is my script "gate.sqs":

Code: [Select]
_unit = _this Select 0
_gate = _this Select 1

? vehicle _unit != _unit: goto "inveh"

exit

#inveh

_gate animate ["Bargate", 0];

exit

the script is called with this trigger:

activation: anyone present repeatedly
on act: {[_x, gate1] exec "gate.sqs"} forEach thislist;

then i place a gate called gate1 like from your example mission and have another trigger with:
gate1 animate ["Bargate", 1];
so the gate is closed at the start of the mission

ive tested this and it just seems to do nothing when the trigger activates?! is my syntax all wrong?

what i want is for the gate to open when a vehicle approaches and then a second trigger to be called to check if any vehicles are still present in the triggers area before closing the gate. the problem with just closing the gate after a certain length of time is that the might be more traffic on the road.

one other thing, i was considering adding some code so that only group leaders are checked to see if they are in a vehicle by the script so that the script isnt called by every unit in the vehicles cargo. something like:

Code: [Select]
_grp = group _unit
? _unit != leader _grp: goto "exitscript"

« Last Edit: 16 May 2007, 01:06:42 by genji »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #12 on: 16 May 2007, 01:41:31 »
You did it exactly how I was thinking.  But now I think thislist includes the vehicle as a member of thislist, rather than individual humans in the vehicle.  So, I'm thinking that changing the condition to this might work:

Code: [Select]
? vehicle _unit != DRIVER _unit: goto "inveh"

If the unit being tested is a vehicle, then the above test should be true (vehicle will not equal driver). IF the unit being tested is a human on foot, then vehicle and driver will both return the same unit (and the above condition is false).
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Open/Close Gate
« Reply #13 on: 16 May 2007, 03:20:52 »
Code: [Select]
? vehicle _unit != _unitIs the code to check if the unit is in a vehicle or not. If a unit is not in a vehicle then
Code: [Select]
? vehicle _unit == _unitwill return TRUE.
urp!

Offline genji

  • Members
  • *
Re: Open/Close Gate
« Reply #14 on: 16 May 2007, 03:44:30 »
ok ive almost got something now :)

1st trigger:

activation: anyone present repetedly and gateone
onact: {[_x, gate1] exec "gateo.sqs"} forEach thislist; 

2nd trigger:

activation: anyone present repetedly and traffic1
onact: {[_x, gate1] exec "gatec.sqs"} forEach thislist; 

gateo.sqs opens the gate and gatec.sqs will close the gate when there are no vehicles present.

gateo.sqs:

Code: [Select]
_unit = _this Select 0
_gate = _this Select 1

? vehicle _unit != DRIVER _unit: goto "inveh"
hint "no vehicle present"
Exit

#inveh
gateone=false
traffic1=true
_gate animate ["Bargate", 0];
Exit

gatec.sqs:

Code: [Select]
_unit = _this Select 0
_gate = _this Select 1

? vehicle _unit != DRIVER _unit: goto "inveh"
hint "opening gate"
_gate animate ["Bargate", 1];
traffic1=false
gateone=true
Exit

#inveh
hint "vehicle present"
Exit

There still seems to be problems if multiple units are in the triggers zone (i think perhaps only the 1st unit in the zone is check to see if it is a vehicle for some reason).

Im trying to clarifly how repeating triggers work. The 2nd trigger (with activation: anyone present repetedly and traffic1) needs a soldier stationed in the trigger zone by the gate to re-trigger the 2nd trigger thats set to repetedly i think.

Im close to having it working without the soldier guarding the gate in the trigger zone. The gate opens for vehicles as long as there are not soldiers on foot in the trigger zone when the script is called and closes again if a unit enters the trigger's zone to call the 2nd repeating trigger that activates the gatec.sqs and closes the gate  ???     

can someone help me with the triggers so that they call the two gate opening and closing scripts properly pls? I want the gate opened when a vehcile comes along and closed afterwards when no more vehicles are present.
« Last Edit: 16 May 2007, 03:49:58 by genji »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Open/Close Gate
« Reply #15 on: 16 May 2007, 22:31:41 »
First trigger set to side present and repeatedly Condition:
Code: [Select]
({_x isKindOf "LandVehicle"} count thisList) > 0
Use only one trigger and call your gate closing script from the On Deactivation field.
urp!

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Open/Close Gate
« Reply #16 on: 17 May 2007, 05:52:24 »
Very cool.  I need to learn the object tree to make use of that cool kindof command.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline genji

  • Members
  • *
Re: Open/Close Gate
« Reply #17 on: 17 May 2007, 18:10:45 »
i take my hat off to you Mr.Peanut sir  :)

here's a working solution using your trigger codition that dosnt need a script  :D

make a bar gate named "gate1"

make 2 triggers:

1st trigger
condition:true
onact: gate1 animate ["Bargate", 1];

2nd trigger
rectangle
axis a:30
axis b:5
activation: anyone present repeatedly
condition: ({_x isKindOf "LandVehicle"} count thisList) > 0
on act.: gate1 animate ["Bargate", 0];
on dea.: gate1 animate ["Bargate", 1];

the 1st trigger closes the gate at the start of the mission so its shut to begin with.

the 2nd trigger should be placed as a rectangle with dimensions of about 30 x 5 on the road where the gate is so that any vehicle in the area will open the gate.
« Last Edit: 17 May 2007, 18:14:40 by genji »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Open/Close Gate
« Reply #18 on: 17 May 2007, 19:07:07 »
You can see I am a neophyte at objects too!
Can replace Condition with:
Code: [Select]
( "LandVehicle" countType thisList) > 0
isKindOf is a new ArmA command, but in this case the old OFP command is a little more succinct.
urp!