Jump to content
Sign in to follow this  
willithappen

Issue with setmarkerpos.

Recommended Posts

Hi all,

 

I am currently developing a system that will select random objectives then assign markers to that area so that it is visible.

I have run into an issue with the "SetMarkerPos" command.

 

The error I receive is "Error setmarkerpos: type string, expected Array".

e09822981a.png

 

The reason it is setup below is due to the fact I have 3 objective types.

 

Town Objectives

Primary Objectives

Secondary Objectives

 

The script i have created for setting marker positions for Town and Primary objectives is simple as all that is required is that the markers for those are moved to that designated town.

However, a secondary objective can only exist inside a primary objective and not all of the primary objectives have a secondary objective.

The idea is/was to combine the name of the Primary objective (publicvariable of "mainmark") with secondary_%1 to create the names of the secondary objective markers.

I am then able to see if there is a secondary objective nearby to the randomly selected Primary objective and if there is, move the marker to it to indicate such.

 

however I receive the above mentioned error when trying to set the markers position.

 

I was hoping I could receive assistance in fixing this error either via directing me on how to assign the string into an array so the error stops or by finding another way to achieve this goal.

 

Thanks.

 

 

Below is the script I am using to achieve this goal.

null = execVM "obj\objective_controller.sqf";
 
_distm = getmarkerpos mainmark;
_distt = getmarkerpos townmark;
_dista = _distm distance _distt;
 
if (_dista < 2200) then 
{
execVM "obj\objective_controller.sqf";
};
 
if (_dista > 2200) then
{
_getmarkm = getmarkerpos mainmark;
_showobjectivem = "mark_main_area" setMarkerPos _getmarkm;
_showobjectivem = "mark_main_name" setMarkerPos _getmarkm;
_getmarkt = getmarkerpos townmark;
_showobjectivet = "mark_town_area" setMarkerPos _getmarkt;
_showobjectivet = "mark_town_name" setMarkerPos _getmarkt;
};
 
//-----------------------------------------------------------------------------------------------
//Find secondary nearby
_townsec = format ["secondary_%1",mainmark];
 
_dists = getmarkerpos _townsec;
_secfind = _distm distance _dists;
if (_secfind < 500) then
{
hint format ["placing %1 in %2 area", _townsec, mainmark];
_showobjectivesec = "mark_secondary_area" setMarkerPos _townsec;
_showobjectivesec = "mark_secondary_name" setMarkerPos _townsec;
};
if (_secfind > 500) then
{
};

Share this post


Link to post
Share on other sites

It's simply because _townsec is a string and not an array.

-edit-

change it to _dists since that is the actual position

Share this post


Link to post
Share on other sites

Wowee, many thanks on speed of your response.

I can't believe I missed that... 

Share this post


Link to post
Share on other sites

maybe not... thought i saw something but if its a global that might be right

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  

×