Northup 20 Posted June 20, 2022 I need to get the position 6 markers. All markers follow a naming convention kavala_tower_1, pyrgos_tower_1, kavala_tower_2, pyrgos_tower_2 (every zone has 6 towers, 26 zones) etc. I have set up a trigger that will execute the following script: [] spawn { waitUntil{!isNull findDisplay 12}; findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",{ (_this select 0) drawIcon [ getMissionPath "\images\tower1_ca.paa", [1,1,1,1], getMarkerPos "kavala_tower_1", 20, 20, 0, "", false, 0.03, "TahomaB", "right"]; }]; }; //Rinse, wash repeat for towers 2, 3, 4, 5, and 6. While that works, it seems needlessly convoluted and time consuming. Instead, is there a way to get the script script to return every marker named ANYCITY_tower_1, ANYCITY_tower 2 only within the trigger zone? Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 20, 2022 getting all markers in a trigger area: _all_markers_in_trigger_area = allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME }; getting all markers which have tower in marker name and which are in area of trigger: _all_tower_markers_in_trigger_area = allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME && "tower" in _x}; repeating your script for all tower markers in trigger zone: [] spawn { waitUntil{!isNull findDisplay 12}; { findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",{ (_this select 0) drawIcon [ getMissionPath "\images\tower1_ca.paa", [1,1,1,1], getMarkerPos _x, 20, 20, 0, "", false, 0.03, "TahomaB", "right"]; }]; } forEach ( allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME && "tower" in _x } ); }; Nothing tested! Share this post Link to post Share on other sites
Northup 20 Posted June 20, 2022 2 hours ago, sarogahtyp said: getting all markers in a trigger area: _all_markers_in_trigger_area = allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME }; getting all markers which have tower in marker name and which are in area of trigger: _all_tower_markers_in_trigger_area = allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME && "tower" in _x}; repeating your script for all tower markers in trigger zone: [] spawn { waitUntil{!isNull findDisplay 12}; { findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",{ (_this select 0) drawIcon [ getMissionPath "\images\tower1_ca.paa", [1,1,1,1], getMarkerPos _x, 20, 20, 0, "", false, 0.03, "TahomaB", "right"]; }]; } forEach ( allMapMarkers select { getMarkerPos _x inArea triggerArea YOURTRIGGERNAME && "tower" in _x } ); }; Nothing tested! Thanks for the reply! Unfortunately that threw an error type bool, expected number. Line 23. Also, perhaps I should have mentioned each tower has its own numbered icon. So tower1_ca.paa has to appear at tower_1 marker location. My lizard brain attempted to also initially tried to pass "thistrigger" from the trigger to the sqf, so that the sqf isn't relying on the name of the trigger, but rather activates when any trigger calls it. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 20, 2022 9 minutes ago, Northup said: Error type bool, expected number. Line 23. this does not tell anything. https://community.bistudio.com/wiki/Crash_Files#Location and don't post the complete file. the lines related to the error only pls. Edit: Also post the script YOU executed. Not just quoting mine! To make it short: Provide accurate and complete information that is as short as possible! Share this post Link to post Share on other sites
Larrow 2828 Posted June 20, 2022 _x will be unknown in the event (getMarkerPos) 1 Share this post Link to post Share on other sites
Northup 20 Posted June 20, 2022 14 hours ago, Larrow said: _x will be unknown in the event (getMarkerPos) Hide contents [] spawn { private "_map"; waitUntil{ _map = findDisplay 12 displayCtrl 51; !isNull _map }; //Just incase this is run again if ( !isNil "TAG_towerMarkersDraw" ) then { _map ctrlRemoveEventHandler[ "Draw", TAG_towerMarkersDraw ]; }; //Replace YOURTRIGGERNAME with name of trigger given in editor TAG_towerMarkers = allMapMarkers select { "tower" in _x && { getMarkerPos _x inArea YOURTRIGGERNAME } } apply{ [ _x, _x splitString "_" select 2 ] }; TAG_towerMarkersDraw = _map ctrlAddEventHandler[ "Draw", { params[ "_map" ]; //No point drawing icons if they cannot be seen if ( visibleMap || visibleGPS ) then { { _x params[ "_marker", "_id" ]; //Make sure the marker still exists if ( getMarkerPos _marker isNotEqualTo [0,0,0] ) then { _map drawIcon[ getMissionPath format[ "\images\tower%1_ca.paa", _id ], [1,1,1,1], getMarkerPos _marker, 20, 20, 0, "", false, 0.03, "TahomaB", "right" ]; }; } forEach TAG_towerMarkers; }; }]; }; untested This works great for a specific trigger. Is there a way to pass thistrigger instead of yourtriggername? Or perhaps any activated trigger with "TowerTrigger" in the name? The goal is to be able to plop a trigger, have it call a script that does the above, but for any trigger. Using this would still require 26 scripts. Apologies, I am fairly new at this. Share this post Link to post Share on other sites
Larrow 2828 Posted June 21, 2022 (edited) EDIT: Changed my mined after re-reading, multiple triggers would overwrite event and markers draw queue. Spoiler [ thisTrigger ] spawn { params[ "_trigger" ]; private "_map"; waitUntil{ _map = findDisplay 12 displayCtrl 51; !isNull _map }; _towerMarkers = allMapMarkers select { "tower" in _x && { getMarkerPos _x inArea _trigger } } apply{ [ _x, _x splitString "_" select 1 ] }; //If Draw event is already running just add markers to draw queue if ( !isNil "TAG_towerMarkersDraw" ) exitWith { { TAG_towerMarkers pushBackUnique _x; }forEach _towerMarkers; }; TAG_towerMarkers = _towerMarkers; //Path for tower icon files TAG_towerIconPath = "images\tower%1_ca.paa"; TAG_towerMarkersDraw = _map ctrlAddEventHandler[ "Draw", { params[ "_map" ]; //No point drawing icons if they cannot be seen if ( visibleMap || visibleGPS ) then { { _x params[ "_marker", "_id" ]; //Make sure the marker still exists if ( getMarkerPos _marker isNotEqualTo [0,0,0] ) then { _map drawIcon[ getMissionPath format[ TAG_towerIconPath, _id ], [1,1,1,1], getMarkerPos _marker, 20, 20, 0, "", false, 0.03, "TahomaB", "right" ]; }; } forEach +TAG_towerMarkers; }; }]; }; Better yet would be making code into a function rather than pasting the same code in multiple triggers. Then again ditching the triggers altogether and just running a function from postInit would make more sense, as from what you have written the triggers sound like they do nothing other than adding icons at mission start. Edited June 21, 2022 by Larrow Share this post Link to post Share on other sites
Northup 20 Posted June 21, 2022 3 hours ago, Larrow said: EDIT: Changed my mined after re-reading, multiple triggers would overwrite event and markers draw queue. Hide contents [ thisTrigger ] spawn { params[ "_trigger" ]; private "_map"; waitUntil{ _map = findDisplay 12 displayCtrl 51; !isNull _map }; _towerMarkers = allMapMarkers select { "tower" in _x && { getMarkerPos _x inArea _trigger } } apply{ [ _x, _x splitString "_" select 1 ] }; //If Draw event is already running just add markers to draw queue if ( !isNil "TAG_towerMarkersDraw" ) exitWith { { TAG_towerMarkers pushBackUnique _x; }forEach _towerMarkers; }; TAG_towerMarkers = _towerMarkers; //Path for tower icon files TAG_towerIconPath = "images\tower%1_ca.paa"; TAG_towerMarkersDraw = _map ctrlAddEventHandler[ "Draw", { params[ "_map" ]; //No point drawing icons if they cannot be seen if ( visibleMap || visibleGPS ) then { { _x params[ "_marker", "_id" ]; //Make sure the marker still exists if ( getMarkerPos _marker isNotEqualTo [0,0,0] ) then { _map drawIcon[ getMissionPath format[ TAG_towerIconPath, _id ], [1,1,1,1], getMarkerPos _marker, 20, 20, 0, "", false, 0.03, "TahomaB", "right" ]; }; } forEach +TAG_towerMarkers; }; }]; }; Better yet would be making code into a function rather than pasting the same code in multiple triggers. Then again ditching the triggers altogether and just running a function from postInit would make more sense, as from what you have written the triggers sound like they do nothing other than adding icons at mission start. So multiple triggers exist, one for each zone. Only one trigger can be active. You are correct in that all the triggers do is add icons to specific areas of the map. The idea is that only icons in the active zone are shown. Active zone lasts the entire mission (MP), then a new zone is loaded on the next mission. Not sure how else I could show these icons on the map without a trigger in each zone, without also showing every tower on altis called "tower_1", etc. My next step would be to delete all other triggers as soon as one is activated, but not sure if that approach is the best one. You've given me something to chew on though! Edit: Didn't realize this would ditch the sqf, so took me a minute but it works as it (minus the comments, obv.)! Thanks! Share this post Link to post Share on other sites
Larrow 2828 Posted June 22, 2022 23 hours ago, Northup said: Didn't realize this would ditch the sqf, Sorry didnt realise it was a script file and just presumed you were dumping this code straight in triggers activation. Change... [ thisTrigger ] spawn { ...to... _this spawn { ...and then in your trigger (presume you were execVM code)... [ thisTrigger ] execVM "pathToScript"; ...to move code back to a stand-alone script file. Share this post Link to post Share on other sites
Northup 20 Posted June 22, 2022 1 hour ago, Larrow said: Sorry didnt realise it was a script file and just presumed you were dumping this code straight in triggers activation. Change... [ thisTrigger ] spawn { ...to... _this spawn { ...and then in your trigger (presume you were execVM code)... [ thisTrigger ] execVM "pathToScript"; ...to move code back to a stand-alone script file. No worries! Both approaches are helpful. Thanks! Share this post Link to post Share on other sites