Jump to content
Sign in to follow this  
kiptanoi

Create trigger in script, how to?

Recommended Posts

I am trying to make a trigger with a script file.

But it goes not so good.

and I am looking at this example they have on the page where u can find Scripting Commands for ArmA2

http://community.bistudio.com/wiki/createTrigger

Now here is the example

_trg=createTrigger["EmptyDetector",getPos player];
_trg setTriggerArea[5,5,0,false];
_trg setTriggerActivation["CIV","PRESENT",true];
_trg setTriggerStatements["this", "hint 'Civilian near player'", "hint 'no civilian near'"]; 

And this is mine

_trig = createTrigger ["distanceCheck12", [0,0,0]]; 
_trig setTriggerArea [0, 0, 0, false];
_trig setTriggerActivation ["NONE", "present", true];
_trig setTriggerTimeout [0, 0, 0, true]; 
_trig setTriggerStatements ["player distance pilot11<= 20", "player exec "PilotPopSmoke.sqs"" , ""];

And I have try this

_trig = createTrigger ["distanceCheck12", [0,0,0]]; 
_trig setTriggerArea [0, 0, 0, false];
_trig setTriggerActivation ["NONE", "present", true];
_trig setTriggerTimeout [0, 0, 0, true]; 
_trig setTriggerStatements ["player distance pilot11<= 20", player exec "PilotPopSmoke.sqs" , ""];

Then the pilot is throwing smoke where ever I am on the map..

And I have try some others to... but I dont get it to work.

Anyone knows how it should look like when its right?

Please let me know :D

Thanks

Share this post


Link to post
Share on other sites

I'm always use "EmptyDetector" - it's not label but name of some class. So maybe your "distanceCheck12" is the problem?

is

Share this post


Link to post
Share on other sites
I'm always use "EmptyDetector" - it's not label but name of some class. So maybe your "distanceCheck12" is the problem?

is

Dont know, I have read some other trigger problem, and they say something about have 2 "" insted of one...

But I have tryed out all kind of stuff, with one " and with 2 "" at diffrent locations.... but I dont get it right... it will not work. and I need 2 more of this triggers in my mission... =/

And I dont know if "this" in setTriggerStatements are going to be there or if I should have my statement there...

Share this post


Link to post
Share on other sites

_trig = createTrigger ["EmptyDetector", [0,0,0]]; 
_trig setTriggerArea [0, 0, 0, false];
_trig setTriggerActivation ["NONE", "present", true];
_trig setTriggerStatements ["player distance pilot11<= 20", "player exec ""PilotPopSmoke.sqs""" , ""];

Just look closely how many close quotation marks I've used. And it is allways EmptyDetector.

Xeno

Share this post


Link to post
Share on other sites
_trig = createTrigger ["EmptyDetector", [0,0,0]]; 
_trig setTriggerArea [0, 0, 0, false];
_trig setTriggerActivation ["NONE", "present", true];
_trig setTriggerStatements ["player distance pilot11<= 20", "player exec ""PilotPopSmoke.sqs""" , ""];

Just look closely how many close quotation marks I've used. And it is allways EmptyDetector.

Xeno

That did work.... then it must have been this EmptyDetector thing that was the problem, because i think I have try all other combinations today on this

_trig setTriggerStatements ["player distance pilot11<= 20", "player exec ""PilotPopSmoke.sqs""" , ""];[/code] :D

Now... how do I delete this trigger if I want to... it have no name now?

I want to name it to distanceCheck and later delete it with

DeleteVehicle distanceCheck;

---------- Post added at 15:33 ---------- Previous post was at 15:03 ----------

I did this to resolve the name problem.

when I created the fisrt one I use "_trig"

Then I used this when trigger is active and used

_trig setTriggerStatements ["false", "", ""];

Then I create a other trigger with

"_trig1"

Then deactivated it with

_trig1 setTriggerStatements ["false", "", ""];

It was the solution I could find... at I run it just now, and everyting works fine now.

Thank you for help.

Share this post


Link to post
Share on other sites

Hey all, I need help with creating a trigger in a script too. Something is wrong here, because it is not working, even when all the east soldiers are dead in this trigger.

Mission1KumyrnaTrigger1 = createTrigger["EmptyDetector",[getmarkerPos Mission1marker select 0,getmarkerPos Mission1marker select 1,0]];
Mission1KumyrnaTrigger1 setTriggerArea [125,100,27,false];
Mission1KumyrnaTrigger1 setTriggerActivation ["EAST","NOT PRESENT",true];
Mission1KumyrnaTrigger1 setTriggerTimeout [0,0,0,false];
Mission1KumyrnaTrigger1 setTriggerStatements ["this", "deleteGroup M1_Guglovo_enemies; hint 'Mission updated';mission1kumyrna setSimpleTaskDescription ["Report back to the commander for debriefing","Liberation","Liberated"];mission1kumyrna setSimpleTaskDestination (getMarkerPos "SpawnKUMYRNACommander");commander1 addAction ["Debrief","mission1Kumyrnadebrief.sqf"];",""];

I think that there's a problem with the last line

Share this post


Link to post
Share on other sites
Hey all, I need help with creating a trigger in a script too. Something is wrong here, because it is not working, even when all the east soldiers are dead in this trigger.

Mission1KumyrnaTrigger1 = createTrigger["EmptyDetector",[getmarkerPos Mission1marker select 0,getmarkerPos Mission1marker select 1,0]];
Mission1KumyrnaTrigger1 setTriggerArea [125,100,27,false];
Mission1KumyrnaTrigger1 setTriggerActivation ["EAST","NOT PRESENT",true];
Mission1KumyrnaTrigger1 setTriggerTimeout [0,0,0,false];
Mission1KumyrnaTrigger1 setTriggerStatements ["this", "deleteGroup M1_Guglovo_enemies; hint 'Mission updated';mission1kumyrna setSimpleTaskDescription ["Report back to the commander for debriefing","Liberation","Liberated"];mission1kumyrna setSimpleTaskDestination (getMarkerPos "SpawnKUMYRNACommander");commander1 addAction ["Debrief","mission1Kumyrnadebrief.sqf"];",""];

I think that there's a problem with the last line

Mission1KumyrnaTrigger1 setTriggerStatements ["this", "deleteGroup M1_Guglovo_enemies; hint 'Mission updated';mission1kumyrna setSimpleTaskDescription ["Report back to the commander for debriefing","Liberation","Liberated"];mission1kumyrna setSimpleTaskDestination (getMarkerPos "SpawnKUMYRNACommander");commander1 addAction ["Debrief","mission1Kumyrnadebrief.sqf"];",""];

The statement Array has Stirng fields so each field is in "" IE. "Cond","IfTrue","IfFalse"]

So your problem might be where you only use a single " mark around some of the objects or names, try to make every " sign in side a Array string "" that way after the code is read you will have your single " mark as needed.

Normally you'd see some errors in your Arma2.rpt file about missing ; signs or other errors related to the code. If you don't get any errors just recheck your code very carefully step for step.

Hope that helps.

Share this post


Link to post
Share on other sites

I'm having one helluva time getting this trigger to create.

Basically I have 3 markers on the map named "CT1", "WHQ1" and "WHQ2" plus my player and his group on the map.

In my init I have:

[]execVM "Scripts\Test\Trigger.sqf";

Then the Trigger.sqf:

_trg1 = createTrigger["EmptyDetector", getMarkerPos "CT1"];
_trg1 setTriggerArea[50,50,0,false];
_trg1 setTriggerActivation["LEADER","PRESENT",false];
_trg1 setTriggerStatements["this","nul=[this] execVM ""Scripts\Spawn\Spawngroup1.sqf""; "hint 'Done!'"",""];

hint "Done!";

When a player enter the area near the marker it should spawn 2 groups.

And here's that code:

GroupW1 = CreateGroup WEST;
_w1u1 = GroupW1 createUnit ["ACE_SF_FR_TL", [(getpos WHQ1) select 0,(getpos WHQ1) select 1,0], [], 30, "NONE"];
_w1u2 = GroupW1 createUnit ["ACE_SF_FR_Assault_R", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_w1u3 = GroupW1 createUnit ["ACE_SF_FR_Corpsman", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_w1u4 = GroupW1 createUnit ["ACE_SF_FR_Assault_GL", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_w1u5 = GroupW1 createUnit ["ACE_SF_FR_Marksman", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_w1u6 = GroupW1 createUnit ["ACE_SF_FR_AR", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_w1u7 = GroupW1 createUnit ["ACE_SF_FR_Sapper", [(getpos _w1u1) select 0,(getpos _w1u1) select 1,0], [], 18, "NONE"];
_wp = GroupW1 addWaypoint [position _w1u1, 0];
_wp setWaypointType "SAD"; 
_wp setWaypointSpeed "FULL";
_wp setWaypointCombatMode "YELLOW";
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointFormation "FILE";


GroupW2 = CreateGroup WEST;
_w2u1 = GroupW2 createUnit ["ACE_SF_FR_TL", [(getpos WHQ2) select 0,(getpos WHQ2) select 1,0], [], 30, "NONE"];
_w2u2 = GroupW2 createUnit ["ACE_SF_FR_Assault_R", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_w2u3 = GroupW2 createUnit ["ACE_SF_FR_Corpsman", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_w2u4 = GroupW2 createUnit ["ACE_SF_FR_Assault_GL", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_w2u5 = GroupW2 createUnit ["ACE_SF_FR_Marksman", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_w2u6 = GroupW2 createUnit ["ACE_SF_FR_AR", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_w2u7 = GroupW2 createUnit ["ACE_SF_FR_Sapper", [(getpos _w2u1) select 0,(getpos _w2u1) select 1,0], [], 18, "NONE"];
_wp = GroupW1 addWaypoint [position _w2u1, 0];
_wp setWaypointType "GUARD"; 
_wp setWaypointSpeed "FULL";
_wp setWaypointCombatMode "YELLOW";
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointFormation "FILE";

I'm pretty sure it's not the spawn group script cause I used it in another test mission. I'm pretty sure it's the trigger script since I get no done hints.

Does anyone have any suggestions?

Share this post


Link to post
Share on other sites

try this

_trg1 = createTrigger["EmptyDetector", getMarkerPos "CT1"];

_trg1 setTriggerArea[50,50,0,false];

_trg1 setTriggerActivation["LEADER","PRESENT",false];

_trg1 setTriggerStatements["this","nul=[this] execVM 'Scripts\Spawn\Spawngroup1.sqf'; hint 'Done!'; ",""];

Share this post


Link to post
Share on other sites

Not sure why but that doesn't work either. I still get no done hint or units spawned.

Share this post


Link to post
Share on other sites

I'll try that as well but I need the LEADER eventually.

Edited by Manzilla

Share this post


Link to post
Share on other sites

i dunno what that leader does thats y i said that, make sure your actually getting the trigger activated make it a bit bigger...

so you need the leader of what any group that goes into it?

Share this post


Link to post
Share on other sites

EDIT:

S*&T! That was it. I'm not sure why leader does it work though, it's in the comref as an option.

Hmmmm.

Any suggestions on syncing this to the group leader(player in this instance but my not be in another spot in the mission)?

Share this post


Link to post
Share on other sites

for player detection

_trgc_2 = createTrigger["EmptyDetector",getMarkerPos "c1"];

_trgc_2 setTriggerArea[50,50,0,false];

_trgc_2 setTriggerActivation["WEST","PRESENT",false];

_trgc_2 setTriggerStatements["player in thislist","

",""];

for anyunit detection you would have to name the unit or varname the unit and do

unitname in thislist

Share this post


Link to post
Share on other sites

Beautiful! Yes I was using that but I never thought about the unit name. I wonder why the "LEADER", "GROUP", etc. is in the comref if they don't work? I wonder if it's different from A1 and not changed.

Thanks a lot!

Share this post


Link to post
Share on other sites

You get those options when you group an unit to the trigger in editor. So, I guess they were just "datamined" and put up there without actually testing. None of that syncing/grouping stuff works with dynamically created objects. :( Instead, you have to use the setstatement.

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  

×