OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: R0adrunner on 08 Feb 2007, 18:11:49
-
Is there anybody who know how too open/glose the "Bar Gate" in ArmA with a trigger? ???
-
Here ya go:
// 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:
// 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...
-
Thanks Johnnyboy :good:
It works, but the animation is "laggy" :thumbsdown:
-
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...
-
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 ???
-
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..
-
ok mate ... thanx for clearing that up ! :good:
-
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.
-
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:
((position player) nearestObject 123) animate ["Bargate", 1];
123 would be the object ID of the bargate.
My Arma version is also 1.05.
-
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?
-
Right now the trigger is set up to look for a single vehicle named "stryker":
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.
-
thanks johhnyboy for the quick reply
here is my script "gate.sqs":
_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:
_grp = group _unit
? _unit != leader _grp: goto "exitscript"
-
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:
? 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).
-
? vehicle _unit != _unit
Is the code to check if the unit is in a vehicle or not. If a unit is not in a vehicle then
? vehicle _unit == _unit
will return TRUE.
-
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:
_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:
_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.
-
First trigger set to side present and repeatedly Condition:
({_x isKindOf "LandVehicle"} count thisList) > 0
Use only one trigger and call your gate closing script from the On Deactivation field.
-
Very cool. I need to learn the object tree to make use of that cool kindof command.
-
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.
-
You can see I am a neophyte at objects too!
Can replace Condition with:
( "LandVehicle" countType thisList) > 0
isKindOf is a new ArmA command, but in this case the old OFP command is a little more succinct.