Asmodeuz 54 Posted January 13, 2017 Hello, I went through about 8 pages of search results (using search words marker and trigger) and couldn't find a matching discussion to my problem.. and then when I was switching to page number 9 the forums decided I should wait for X seconds to do another search. Sooo I decided just to create a discussion about my problem rather than wait for the forum to let me continue searching. Let's see if I could put this as simple as possible: - I have multiple triggers - I want to use only one script (.sqf) to create a marker at the exact position of any trigger that gets activated by whatever activation rules I see fit to use - so then I could just spam []exec "xxxx.sqf"; in the OnActivation field of every trigger So far I have a file caparea.sqf _trigger = _this select 0; _marker = createMarker ["capturearea", position _trigger]; "capturearea" setMarkerShape "ELLIPSE"; "capturearea" setMarkerSize [300,300]; "capturearea" setMarkerBrush "SolidBorder"; "capturearea" setMarkerAlpha 1; "capturearea" setMarkerColor "ColorOPFOR"; and then I call it with []exec "caparea.sqf" from the OnActivation field. When testing this combo the game is showing me Error undefined variable in expression: _trigger I doubt that is even close to being correct but I've been trying things together found here and there from the depths of the internet. Any suggestions on how to actually achieve what I'm aiming for here? Share this post Link to post Share on other sites
davidoss 552 Posted January 13, 2017 4 minutes ago, Asmodeuz said: Error undefined variable in expression: _trigger You are passing nothing into your script : []exec "caparea.sqf" -- [] means nothing. you need to set this like this: [thisTrigger] execVm "caparea.sqf" 1 Share this post Link to post Share on other sites
theend3r 83 Posted January 13, 2017 7 minutes ago, Asmodeuz said: caparea.sqf _trigger = _this select 0; _marker = createMarker ["capturearea", position _trigger]; "capturearea" setMarkerShape "ELLIPSE"; "capturearea" setMarkerSize [300,300]; "capturearea" setMarkerBrush "SolidBorder"; "capturearea" setMarkerAlpha 1; "capturearea" setMarkerColor "ColorOPFOR"; and then I call it with []exec "caparea.sqf" from the OnActivation field. When testing this combo the game is showing me Error undefined variable in expression: _trigger I doubt that is even close to being correct but I've been trying things together found here and there from the depths of the internet. Any suggestions on how to actually achieve what I'm aiming for here? The [] in []exec "caparea.sqf" is used to supply variables to the script that show up as _this inside. Therefore in your case _trigger = _this select 0; is equal to _trigger = [] select 0; which is equal to nothing. What you need to do is to exec it as [thisTrigger]exec "caparea.sqf". Edit: Ninja'd 1 Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 13, 2017 Thanks @davidoss and @theend3r for the quick replies! Now the script works like a charm so that when the trigger gets activated a marker will appear directly at the position of the trigger. Though a small correction to davidoss' example: it wasn't possible to use execVM, using it resulted in a error message "On Activation: Type Script, expected Nothing". But using only exec did the trick. Share this post Link to post Share on other sites
davidoss 552 Posted January 13, 2017 null = [thisTrigger] execVm "caparea.sqf" but... for professionalism: null = [getPos thisTrigger] execVm "caparea.sqf" params [ ["_position",[],[[]]] ]; _marker = createMarker ["capturearea", _position]; _marker setMarkerShape "ELLIPSE"; _marker setMarkerSize [300,300]; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR"; Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 13, 2017 Just now, davidoss said: null = [thisTrigger] execVm "caparea.sqf" Mind if I ask is there somekind of difference between the two slightly different versions suggested here? Share this post Link to post Share on other sites
theend3r 83 Posted January 13, 2017 Just a note, using _triggerSize = triggerArea _trigger; "capturearea" setMarkerSize [_triggerSize select 0, _triggerSize select 1]; would make it more universal. Share this post Link to post Share on other sites
davidoss 552 Posted January 13, 2017 null = [getPos thisTrigger, triggerArea thisTrigger] spawn { params [ ["_position",[],[[]]], ["_triggerSize",[],[[]]] ]; private _marker = createMarker ["capturearea", _position]; _marker setMarkerShape "ELLIPSE"; _marker setMarkerSize [_triggerSize select 0, _triggerSize select 1]; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR"; }; Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 13, 2017 Ok ok you pros, thank you for all the small nyances in the scripts but may I ask you to elaborate "what's the difference"? :D Or at least which one of them would be best used in multiplayer scenarios using dedicated server? Share this post Link to post Share on other sites
davidoss 552 Posted January 13, 2017 if (isServer) then { null = [getPos thisTrigger, triggerArea thisTrigger] spawn { params [ ["_position",[],[[]]], ["_triggerSize",[],[[]]] ]; private _marker = createMarker ["capturearea", _position]; _marker setMarkerShape "ELLIPSE"; _marker setMarkerSize [_triggerSize select 0, _triggerSize select 1]; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR"; }; }; If you use this direct in activation field of trigger you do not need any other sqf files. WOOW we got HOT 1 Share this post Link to post Share on other sites
theend3r 83 Posted January 13, 2017 6 minutes ago, davidoss said: WOOW we got HOT Yay, my first time seeing that on these forums. 11 minutes ago, Asmodeuz said: Ok ok you pros, thank you for all the small nyances in the scripts but may I ask you to elaborate "what's the difference"? :D Or at least which one of them would be best used in multiplayer scenarios using dedicated server? Use the null = [] execVM "script.sqf" or remoteExec for MP, exec is deprecated. 1 Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 13, 2017 4 minutes ago, davidoss said: if (isServer) then { null = [getPos thisTrigger, triggerArea thisTrigger] spawn { params [ ["_position",[],[[]]], ["_triggerSize",[],[[]]] ]; private _marker = createMarker ["capturearea", _position]; _marker setMarkerShape "ELLIPSE"; _marker setMarkerSize [_triggerSize select 0, _triggerSize select 1]; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR"; }; }; If you use this direct in activation field of trigger you do not need any other sqf files. WOOW we got HOT Ok ok! But if I use a single .sqf file for that one I will keep the OnActivation fields clutter free since there's already other stuff! :) Yes, some got quite hot indeed :D Share this post Link to post Share on other sites
Larrow 2822 Posted January 13, 2017 There is already a BI function that will do most of the work for you ( BIS_fnc_markerToTrigger ). In trigger null = [ thisTrigger ] execVM "myTrigScript.sqf"; myTrigScript.sqf params[ "_trigger" ]; _marker = [ "captureArea", _trigger ] call BIS_fnc_markerToTrigger; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR" 1 Share this post Link to post Share on other sites
JohnnyHotPockets 1 Posted January 14, 2017 sweet helped a lot thank you Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 14, 2017 8 hours ago, Larrow said: There is already a BI function that will do most of the work for you ( BIS_fnc_markerToTrigger ). In trigger null = [ thisTrigger ] execVM "myTrigScript.sqf"; myTrigScript.sqf params[ "_trigger" ]; _marker = [ "captureArea", _trigger ] call BIS_fnc_markerToTrigger; _marker setMarkerBrush "SolidBorder"; _marker setMarkerAlpha 1; _marker setMarkerColor "ColorOPFOR" I actually saw your reply to a somewhat similar case but childishly enough thought that it will be of no use because the script involves giving a name to the trigger that is placed in the editor. But this version here is one that even I understand "lol!" Thank you @Larrow for another good way to achieve what this topic was looking for. 1 Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 14, 2017 On a sidenote one thing that I didn't understand before I got to test with a script that creates a marker by using only one .sqf file: is that creating multiple markers with only one name (such as "captureArea") leads me to the point that every time a new marker is created an older one that has been invoked with the same method will get removed. So after all I seem to be forced to declare around 30 different markers with unique names in the mission I'm making at the moment. Damn shame really. edit: actually 60 markers because I need 30 markers to display a "neutral" objective, and 30 markers to display a "captured" objective. Then if I want to display objectives that have been captured by the enemy I need another 30 markers totaling to 90 markers... ... .. Share this post Link to post Share on other sites
Larrow 2822 Posted January 14, 2017 Name your triggers in the editor and just change this line.. _marker = [ format["%1_area",vehicleVarName _trigger], _trigger ] call BIS_fnc_markerToTrigger; So the markers get named based on the name of the trigger that called them + _area. 1 Share this post Link to post Share on other sites
Asmodeuz 54 Posted January 14, 2017 2 hours ago, Larrow said: Name your triggers in the editor and just change this line.. _marker = [ format["%1_area",vehicleVarName _trigger], _trigger ] call BIS_fnc_markerToTrigger; So the markers get named based on the name of the trigger that called them + _area. Luckily I had the triggers already names so I could give this iteration a quick test. So I changed the line _marker = [ "captureArea", _trigger ] call BIS_fnc_markerToTrigger; to _marker = [ format["%1_area",vehicleVarName _trigger], _trigger ] call BIS_fnc_markerToTrigger; and the script still works meaning that a marker gets created when a trigger gets activated. But for some reason when one marker has already been created and a trigger gets activated someplace else the earlier marker gets deleted at the same time this new one appears on the map. No idea what's with that but I can say that I don't have a line anywhere that would tell markers to be deleted. Share this post Link to post Share on other sites
TacticalKaos 2 Posted March 23, 2018 Hello, First off this was a great post! very helpful and funny. I'm currently using the script Larrow posted spawning markers on trigger positions and it works excellent, but I would like for the old marker to be deleted once a new one spawns.. Let me explain what I've got going on. I've got 10 Bandit camps spawning in roughly 40 random locations every hour, once they spawn on their starting positions a marker is created letting players know where camps are located, After x amount of time camps are despawned and a cool down period kicks in before they are spawned in 10 new locations. This is where I'd like for the original marker, marker's to be deleted. In it's current state I've got markers popping up every time the camps switch to a new area. I hope I made my situation some what clear and any help would be greatly appreciated. Thanks Kaos Share this post Link to post Share on other sites