Jump to content
Yyo

Marker teleporting to corner of map

Recommended Posts

Hello all, I hope you're doing well. The basis of what I am trying to do is trying to change the position of a marker to another markers position via script. I have this line of code in my initServer.sqf:

 

[] spawn {while {true} do {sleep 5; "MGIRespEastAI" setMarkerPos (getMarkerPos (selectRandom ["EastRESPmkr", "EastRESPmkr_1", "EastRESPmkr_3", "EastRESPmkr_2"]));};};

 

Basically, I am using PierreMGI's amazing addon "MGI Advanced Modules" and using his respawn system for AI. For my scenario, I have a sector placed and I have a trigger synced to an "Unlock" logic that is synced to the sectors module. The trigger will activate/unlock if OPFOR captures the sector. Within this trigger, I have it coded so that it creates markers ("EastRESPmkr_2", "EastRESPmkr_3") on other triggers I positioned around the AO of the sector, acting as potential positions for the "MGIRespEastAI" marker to be randomly teleported. These markers ("EastRESPmkr_2", "EastRESPmkr_3") will than be created if OPFOR captures the sector and would be deleted if OPFOR loses the sector. My other 2 markers ("EastRESPmkr", "EastRESPmkr_1") are acting as my base markers, essentially theses will already be activated upon start of my mission. Everything works as expected, where the "MGIRespEastAI" marker will teleport to either of the base markers, or if activated, would also be teleported to the captured sectors marker positions. But what sometimes happens is that the "MGIRespEastAI" marker will be sometimes positioned/teleported at the corner of the map? I was wondering if there's anything I should add or change about in my sqf file or maybe go a different route of randomly setting the position of a marker to an array of other marker positions? Any help will be greatly appreciated! If any more clarification or even a link for my mission file is needed, please let me know! Stay safe!

Share this post


Link to post
Share on other sites
On 4/15/2023 at 7:24 AM, Yyo said:

I am trying to do is trying to change the position of a marker to another markers position via script. I have this line of code in my initServer.sqf:

On 4/15/2023 at 7:24 AM, Yyo said:

The trigger will activate/unlock if OPFOR captures the sector. Within this trigger, I have it coded so that it creates markers ("EastRESPmkr_2", "EastRESPmkr_3")

On 4/15/2023 at 7:24 AM, Yyo said:

My other 2 markers ("EastRESPmkr", "EastRESPmkr_1") are acting as my base markers, essentially theses will already be activated upon start of my mission.

On 4/15/2023 at 7:24 AM, Yyo said:

But what sometimes happens is that the "MGIRespEastAI" marker will be sometimes positioned/teleported at the corner of the map?

 

As some times the selectRandom in your initServer script is selecting the markers "EastRESPmkr_2" or "EastRESPmkr_3" which have not been created yet/been removed (sector not captured). So getting the position of these markers returns [0,0,0] so the "MGIRespEastAI" gets placed there ([0,0,0] == corner of the map).

[] spawn {
	while {true} do {
		sleep 5;
		//Only markers that currently exist
		_activeMarkers = [ "EastRESPmkr", "EastRESPmkr_1", "EastRESPmkr_3", "EastRESPmkr_2" ] select{ getMarkerPos _x isNotEqualTo [0,0,0] };
		"MGIRespEastAI" setMarkerPos getMarkerPos(selectRandom _activeMarkers);
	};
}; 

 

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, Larrow said:

 

As some times the selectRandom in your initServer script is selecting the markers "EastRESPmkr_2" or "EastRESPmkr_3" which have not been created yet/been removed (sector not captured). So getting the position of these markers returns [0,0,0] so the "MGIRespEastAI" gets placed there ([0,0,0] == corner of the map).


[] spawn {
	while {true} do {
		sleep 5;
		//Only markers that currently exist
		_activeMarkers = [ "EastRESPmkr", "EastRESPmkr_1", "EastRESPmkr_3", "EastRESPmkr_2" ] select{ getMarkerPos _x isNotEqualTo [0,0,0] };
		"MGIRespEastAI" setMarkerPos getMarkerPos(selectRandom _activeMarkers);
	};
}; 

 

Hey Larrow, it's a great honor to have had you solve my problem, you're a legend! Thank you so much, I really appreciate it! Have a wonderful rest of your week and stay safe boss!

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

×