Jump to content
Sign in to follow this  
D. Patterson

Odd Behaviour: Triggers Created Inside a Loop

Recommended Posts

So the loop part of my script is this

for [{_i1=0}, {_i1<_LootSpawnEX}, {_i1=_i1+1}] do 
		{
		_lootcrate = createVehicle ["Land_CratesWooden_F",getMarkerPos "wreckmarkerf1", [], 18, "NONE"];
		Loot_DirEX = Ceil random 360;
		PublicVariable "Loot_DirEX";
		_lootcrate setDir Loot_DirEX;
		_loottrg=createTrigger["EmptyDetector",getPos _lootcrate];
		_loottrg setTriggerArea[3,3,0,false];
		_loottrg setTriggerActivation["ANY","PRESENT",true];
		_loottrg setTriggerStatements ["player in thislist", "LootAddAct = player addAction ['Pickup Treasure', 'pickup.sqf', nil, 1.5, true, true]", "player removeAction LootAddAct;"]
		};

When I go near a spawned crate, I get the action for that crate, however it's hit and miss whether or not the action is removed, on some crates it's removed, on others it stays (Clutters the action menu)

Any ideas what's going wrong?

Share this post


Link to post
Share on other sites

1. Why do you add the actions to the player instead of simply adding the action directly to your treasurecrate?

2. There is NO reason to use a trigger as addAction itself can have a condition that defines exactly when the action should be visible.

Share this post


Link to post
Share on other sites
1. Why do you add the actions to the player instead of simply adding the action directly to your treasurecrate?

2. There is NO reason to use a trigger as addAction itself can have a condition that defines exactly when the action should be visible.

So I changed it to

for [{_i1=0}, {_i1<_LootSpawnEX}, {_i1=_i1+1}] do 
		{
		lootcrate = createVehicle ["Land_CratesWooden_F",getMarkerPos "wreckmarkerf1", [], 18, "NONE"];
		PublicVariable "lootcrate";
		Loot_DirEX = Ceil random 360;
		PublicVariable "Loot_DirEX";
		lootcrate setDir Loot_DirEX;
		lootaddact = lootcrate addAction ["Pickup Treasure", "pickup.sqf", nil, 1.5, true, true,"","true"];
		PublicVariable "lootaddact";
		};

But only the player who used the trigger that activated the script will get the option to "Pickup Treasure"

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  

×