Jump to content
aseliot

createtrigger examlpe not working for me?

Recommended Posts

So i couldn't get createtrigger to work, to test i copied the example from the page into the script.

	_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'"];

But it does not show a hint? I have no idea how to debug this.

Share this post


Link to post
Share on other sites

For that a civilian would need to walk within 5 meters of where you were when that script ran.

 

What script did you copy it into and how did you run that script?

Share this post


Link to post
Share on other sites

Well i understand a hint should print if there is a civ near or not, so should display a hint regardless.

I put it in a script I am sure gets executed, I also put it in the local execution ingame. It doesn't give any warnings or errors.

Share this post


Link to post
Share on other sites

Yeah, that worked for me.   Thing to remember is the trigger is placed where you were standing when you entered the code, so it won't follow you around.  To do that you'd need to change the code slightly.

 

You can attach the trigger to your player by adding this line at the end of the script:

_trg attachTo [player, [0,0,0]];

Then it'll follow you around and as you approach one you'll get a hint and as they fall away again.

Share this post


Link to post
Share on other sites

Ah yes then it does work but i can't figure out why my custom trigger doesn't also work. I have the same conditions as I have with the one placed within the editor.

	_capturetrig = createTrigger ["captrig", position _x];
	_capturetrig setTriggerArea [markerX, markerY, 0, true];
	_capturetrig setTriggerActivation ["ANY", "PRESENT", true];
	_capturetrig setTriggerStatements ["player in thislist", "script = [thislist] execVM 'capture.sqf';", "hint 'bye'"];

_x is location when i place a square marker.

Share this post


Link to post
Share on other sites

Eh, i don't see why you need to attach it to the player when it's repeatable. It doesn't just dissapear after it activates? 

 

Either way my custom one does work.

you ve to attach it if it should follow the player. if u dont attach then the trigger will stay at it position where it was created.

Repeatable means that it can be activated and deactivated more than one time.

Share this post


Link to post
Share on other sites

you ve to attach it if it should follow the player. if u dont attach then the trigger will stay at it position where it was created.

Repeatable means that it can be activated and deactivated more than one time.

Yeah i misread what it should do.

 

But i can't find out why my custom one is not working, also don't know any way to see where the trigger is placed visually from a script.

The capture.sqf works fine when i put it in trigger I place with the editor.

Share this post


Link to post
Share on other sites

You need the "EmptyDetector" in your createTrigger.  That's not the name of the trigger, it's the type of trigger.

	_captrig = createTrigger ["EmptyDetector", position _x]; // Are you running this inside a loop on multiple hostages?  _x is a special variable
	_captrig setTriggerArea [markerX, markerY, 0, true];  // Are markerX and markerY global variables with numbers in them?
	_captrig setTriggerActivation ["ANY", "PRESENT", true];
        _myStatements = format[["player in thislist", "script = [%1] execVM 'capture.sqf';", "hint 'bye']", _x]; // Assuming this is looped
	_captrig setTriggerStatements _myStatements; // Changed this to feed just the current hostage to the script.

To be honest I'd skip the triggers and just go with addActions on each hostage instead.  A lot less pain and code.

Share this post


Link to post
Share on other sites

Ah okay it works now when i use EmptyDetector, i did indeed asume it was the name.

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

×