Jump to content
Assaultimon

Create trigger via script not working

Recommended Posts

Hi,

 

I have following code in my missions initServer.sqf. It spawns 5 random spots where smoke rises in the air. I want to trigger an event as soon as the player steps into the smoke, but so far no luck. I read a lot about triggers and locality. I even tried to create the triggers in initPlayerLocal but i walk where the triggers are supposed to be and nothing happens.

I'm hosting the mission as MP from the editor with no clients..

 

_centre = getMarkerPos "CivMarker";

for "_i" from 1 to 5 do {
	_randDir = random(360);
	_randDist = (random 100) + 100;
	_posx=(_centre select 0) + (_randDist * sin(_randDir));
	_posy= (_centre select 1) + (_randDist * cos(_randDir));
	_pos2d= [_posx, _posy];
	_position =	[_posx, _posy, getTerrainHeightASL (_pos2d)];

	_smoke = "test_EmptyObjectForSmoke" createVehicle _position;
	
//	_trg = createTrigger ["Trigger", _position];
	_trg = createTrigger ["Trigger", _position,false];
	_trg setTriggerArea [10, 10, 0, false];
	_trg setTriggerActivation ["ANYPLAYER", "PRESENT", true];
//	_trg setTriggerStatements ["this", "hint 'Trigger'", "hint 'No Trigger'"];
	_trg setTriggerStatements ["this", "_Smoke = ""SmokeShellRed"" createVehicle (position _this);", "hint 'no trigger'"];
};


 
	

Share this post


Link to post
Share on other sites
2 minutes ago, wogz187 said:

What's that lil' dude doin' there?


};

 

He's SMOKING SOMETHING..LOL

  • Haha 2

Share this post


Link to post
Share on other sites

The problem is in the randomization part of the script.

  • Like 1

Share this post


Link to post
Share on other sites
53 minutes ago, Assaultimon said:

_trg = createTrigger ["Trigger", _position,false];

Hello there Assaultimon !

 

First of all ,

if i remember you must name every trigger with a different name , like :

 

ex:( i'm using this for markers here )

_a = 0;	
_a = _a + 1;


_Marker_id = format ["%1",_pos];
_Marker = createMarker [_Marker_id,_pos];
_Marker setMarkerShape "ICON";
_Marker setMarkerType "mil_marker";
_Marker setMarkerColor "ColorUNKNOWN";
_Marker setMarkerText format ["Airdrop : %1",_a];
_Marker setMarkerSize [1,1];

also try this first with a simple one trigger and a simple hint or systemchat , in order to check the trigger first and then add the code.

  • Like 1

Share this post


Link to post
Share on other sites

+ 1 more ex :

_Trigger = createTrigger ["EmptyDetector", _pos];
_Trigger setTriggerArea [GF_Missions_Attack_Distance, GF_Missions_Attack_Distance, 0, false];
_Trigger setTriggerActivation ["EAST", "PRESENT", false];
_Trigger setTriggerStatements ["this","",""];

 

  • Like 1

Share this post


Link to post
Share on other sites
30 minutes ago, wogz187 said:

What's that lil' dude doin' there?


};

 

 

thats how you are supposed to end the for loop is it not? oO

 

22 minutes ago, wogz187 said:

The problem is in the randomization part of the script.

 

the randomization works fine, the smoke spawns randomly in a given radius around the centre

 

6 minutes ago, GEORGE FLOROS GR said:

Hello there Assaultimon !

 

First of all ,

if i remember you must name every trigger with a different name , like :

 

ex:( i'm using this for markers here )


_a = 0;	
_a = _a + 1;


_Marker_id = format ["%1",_pos];
_Marker = createMarker [_Marker_id,_pos];
_Marker setMarkerShape "ICON";
_Marker setMarkerType "mil_marker";
_Marker setMarkerColor "ColorUNKNOWN";
_Marker setMarkerText format ["Airdrop : %1",_a];
_Marker setMarkerSize [1,1];

also try this first with a simple one trigger and a simple hint or systemchat , in order to check the trigger first and then add the code.

 

I already tried with different trigger names, scrapped it from the posted version to make it shorter. But good to know that it's a must.

 

Also i used the line i commented out in the script above ( _trg setTriggerStatements ["this", "hint 'Trigger'", "hint 'No Trigger'"]; ) 

I will try to only create one trigger without a loop even at player position, though. Running out of options..

  • Like 1

Share this post


Link to post
Share on other sites
4 minutes ago, GEORGE FLOROS GR said:

+ 1 more ex :

 

this ex is better :

_trigger1 = createTrigger ["EmptyDetector", getMarkerPos "Trader1"];
_trigger1 setTriggerArea [400, 400, 0, false];
_trigger1 setTriggerTimeout [0, 0, 0, true]; 
_trigger1 setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_trigger1 setTriggerStatements ["this", "0 = [thistrigger, thisList] call rvg_fnc_safeZone", ""];
_trigger1 setTriggerStatements ["this", "hint 'Enter SafeZone'", "hint 'Exit SafeZone'"];

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Assaultimon said:

createTrigger ["Trigger"

createTrigger[ "EmptyDetector"
Quote

The type must be a class name in CfgNonAIVehicles or CfgVehicles with simulation = detector.

Spoiler

_centre = getMarkerPos "CivMarker";

for "_i" from 1 to 5 do {
	_position = _center getPos[ ( random 100 ) + 100, random 360 ];
	
	_smoke = "test_EmptyObjectForSmoke" createVehicle _position;
	
	_trg = createTrigger[ "EmptyDetector", _position, false ];
	_trg setTriggerArea[ 10, 10, 0, false ];
	_trg setTriggerActivation[ "ANYPLAYER", "PRESENT", true ];
	_trg setTriggerStatements[
		"this",
		"'SmokeShellRed' createVehicle getPosATL _thisTrigger;",
		"hint 'Trigger DeActivated'"
	];
};

 

  • Like 3

Share this post


Link to post
Share on other sites

Larrow, you're the MAN! Trigger name = "EmptyDetector" and it works. No need to use different names, should've read the wiki page more carefully. My bad!

 

Thanks for all the help!

 

 

  • Like 2

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

×