Fr3eMan 16 Posted January 26, 2018 Hi all! I'm trying to create a dynamic multiple trigger script for automate the creation and delete of triggers around some specific areas. The part of creation almost working nice using the below code, but if I try to delete the trigger by deleteVehicle command the trigger aren't deleted, so I think the problem is the name I give to the trigger is not really used during the triggers creation, I'm for sure missing something but I really have no idea what. _Triggers = [ ["trigger0",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger1",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger2",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger3",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]] ]; { _trigger = _x select 0; _pos = _x select 1; _size = _x select 2; _trigger = createTrigger ["EmptyDetector",_pos]; _trigger setTriggerArea _size; _trigger setTriggerActivation ["EAST","PRESENT",true]; _trigger setTriggerStatements ["this","{deletevehicle _x} forEach thislist;",""]; } forEach _Triggers; Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted January 26, 2018 Where exactly are you deleting the trigger? Cheers Share this post Link to post Share on other sites
Fr3eMan 16 Posted January 26, 2018 4 minutes ago, Grumpy Old Man said: Where exactly are you deleting the trigger? Cheers In another trigger, when the area become captured by players, the trigger activation have in the setTriggerStatements the deleteVehicle _trigger = createTrigger ["EmptyDetector",(getMarkerPos _marker)]; _trigger setTriggerArea [500,500,0,false,100]; _trigger setTriggerActivation ["EAST","NOT PRESENT",false]; _trigger setTriggerStatements ["this","hint 'Area Clear'; deleteVehicle trigger0; deleteVehicle trigger1; deleteVehicle trigger2; deleteVehicle trigger3; deleteVehicle thisTrigger;",""]; Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted January 26, 2018 I see, here goes: _Triggers = [ ["trigger0",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger1",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger2",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger3",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]] ]; { _trigger = _x select 0;//this will declare _trigger as "trigger0", next iteration "trigger1" _pos = _x select 1; _size = _x select 2; //but here is the culprit, this will make the above _trigger invalid and replace it with an object instead of a string _trigger = createTrigger ["EmptyDetector",_pos]; _trigger setTriggerArea _size; _trigger setTriggerActivation ["EAST","PRESENT",true]; _trigger setTriggerStatements ["this","{deletevehicle _x} forEach thislist;",""]; } forEach _Triggers; To clear it up, _trigger is first defined as a string but will be overridden since the createTrigger command returns the trigger object. You can work around this if you push all created triggers in a global array and delete all triggers in the array from any other captured trigger, like this: TAG_list_myTriggers = []; _Triggers = [ ["trigger0",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger1",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger2",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]], ["trigger3",[_posX,_posY,_posZ],[_sizeA,_sizeB,_dir,true,_sizeH]] ]; { _trigger = _x select 0;//this line is no longer needed _pos = _x select 1; _size = _x select 2; _trigger = createTrigger ["EmptyDetector",_pos]; TAG_list_myTriggers pushBack _trigger;//this stores the trigger object inside the global array _trigger setTriggerArea _size; _trigger setTriggerActivation ["EAST","PRESENT",true]; _trigger setTriggerStatements ["this","{deletevehicle _x} forEach thislist;",""]; } forEach _Triggers; //now inside your other trigger snippet: _trigger = createTrigger ["EmptyDetector",(getMarkerPos _marker)]; _trigger setTriggerArea [500,500,0,false,100]; _trigger setTriggerActivation ["EAST","NOT PRESENT",false]; _trigger setTriggerStatements ["this","hint 'Area Clear'; //this will delete every trigger in the global array {deleteVehicle _x} forEach TAG_list_myTriggers; ",""]; Unless I misunderstood. Cheers 1 Share this post Link to post Share on other sites
Schatten 290 Posted January 26, 2018 @Fr3eMan, you incorrectly assign value of variable. You need to use call or setVariable to do this: _triggerVarName = "trigger0"; call (compile (format ["%1 = createTrigger ['EmptyDetector', _position];", _triggerVarName])); or _triggerVarName = "trigger0"; _trigger = createTrigger ["EmptyDetector", _position]; missionNamespace setVariable [_triggerVarName, _trigger]; Now you can use deleteVehicle to delete trigger. 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 27, 2018 here is how i would do this: //create triggers = []; _positions = [[_posX,_posY,_posZ],[_posX,_posY,_posZ],[_posX,_posY,_posZ],[_posX,_posY,_posZ]]; _size = [_sizeA,_sizeB,_dir,true,_sizeH]; { triggers pushBack createTrigger ["EmptyDetector",_x]; } forEach _positions; { _x setTriggerArea _size; _x setTriggerActivation ["EAST","PRESENT",true]; _x setTriggerStatements ["this","{deleteVehicle _x} forEach thisList;",""]; } forEach triggers; //remove {deleteVehicle _x} forEach triggers; 1 Share this post Link to post Share on other sites
Fr3eMan 16 Posted January 27, 2018 Looks like the pushBack command doesn't work, I did already some test with it before write here, I try also to use the both code by Grumpy and Davidoss but nothing the trigger remain present, I try also Schatten suggestion but nothing, test done in editor, all codes was executed by remoteExec command line and in both condition 0 (globally) and 2 (only server side). Share this post Link to post Share on other sites
davidoss 552 Posted January 27, 2018 5 minutes ago, Fr3eMan said: Looks like the pushBack command doesn't work Impossible Share this post Link to post Share on other sites
Fr3eMan 16 Posted January 27, 2018 24 minutes ago, davidoss said: Impossible You right, it work with only one trigger size, I try to adapt with different size and doesn't work, I to do more test. Share this post Link to post Share on other sites
davidoss 552 Posted January 27, 2018 I didn't knew your need different sizes because your variables are the same. Here are the same code for different sizes ,keep in mind _sizes array need to have the same index count as _positions array and correlated each other //create triggers = []; _positions = [[_posX,_posY,_posZ],[_posX,_posY,_posZ],[_posX,_posY,_posZ],[_posX,_posY,_posZ]]; _sizes = [[_sizeA,_sizeB,_dir,true,_sizeH],[_sizeA,_sizeB,_dir,true,_sizeH],[_sizeA,_sizeB,_dir,true,_sizeH],[_sizeA,_sizeB,_dir,true,_sizeH]]; { triggers pushBack createTrigger ["EmptyDetector",_x]; } forEach _positions; { _x setTriggerArea (_sizes select _forEachIndex); _x setTriggerActivation ["EAST","PRESENT",true]; _x setTriggerStatements ["this","{deleteVehicle _x} forEach thisList;",""]; } forEach triggers; //remove {deleteVehicle _x} forEach triggers; 1 Share this post Link to post Share on other sites
Fr3eMan 16 Posted January 27, 2018 34 minutes ago, davidoss said: Here are the same code for different sizes ,keep in mind _sizes array need to have the same index count as _positions array That's working nice, thanks all for assistance! Share this post Link to post Share on other sites