Jump to content
Sign in to follow this  
cael817

Create map markers if object has a certain variable.

Recommended Posts

So i found several ways to create map markers depending on for example classname

_number = 0;
_vehicle = nearestObjects [player, ["car"], 20000];
{
_number = _number + 1;
_markername = format ["%1_%2", typeOf _x, _number];
_vehicleMarker = createMarkerLocal [_markername, position _x];
_vehicleMarker setMarkerShapeLocal "ICON";
_vehicleMarker setMarkerTypeLocal "mil_dot";
       _vehicleMarker setMarkerTextLocal "Your stuff is here";
_vehicleMarker setMarkerColorLocal "ColorRed";

} forEach _vehicle;

What i want to do is to find all vehicles and or objects that have the variable "ownerUID" set to it and preferably compare this to the playerUID, and if it matches draw a private marker on the map and then remove it after a set time.

I have problems figuring out both how to find and mark objects/vehicles based on a variable instead of classname and how to use

deleteMarkerLocal _vehicleMarker;

in conjunction with the above code, if this way even is a good idea? Goal is for it to work on a dedicated server.

Any help is appreciated. :)

Share this post


Link to post
Share on other sites
So i found several ways to create map markers depending on for example classname

_number = 0;
_vehicle = nearestObjects [player, ["car"], 20000];
{
_number = _number + 1;
_markername = format ["%1_%2", typeOf _x, _number];
_vehicleMarker = createMarkerLocal [_markername, position _x];
_vehicleMarker setMarkerShapeLocal "ICON";
_vehicleMarker setMarkerTypeLocal "mil_dot";
       _vehicleMarker setMarkerTextLocal "Your stuff is here";
_vehicleMarker setMarkerColorLocal "ColorRed";

} forEach _vehicle;

What i want to do is to find all vehicles and or objects that have the variable "ownerUID" set to it and preferably compare this to the playerUID, and if it matches draw a private marker on the map and then remove it after a set time.

I have problems figuring out both how to find and mark objects/vehicles based on a variable instead of classname and how to use

deleteMarkerLocal _vehicleMarker;

in conjunction with the above code, if this way even is a good idea? Goal is for it to work on a dedicated server.

Any help is appreciated. :)

simply get your array of objects then put an if statement inside the foreach loop (we'll use _x as that is replaced by whatever foreach is currently looking at

_number = 0;
_vehicle = nearestObjects [player, ["car"], 20000];
{
      if(_x getVariable "ownerUID" == getplayerUID player) then
      {
_number = _number + 1;
_markername = format ["%1_%2", typeOf _x, _number];
_vehicleMarker = createMarkerLocal [_markername, position _x];
_vehicleMarker setMarkerShapeLocal "ICON";
_vehicleMarker setMarkerTypeLocal "mil_dot";
       _vehicleMarker setMarkerTextLocal "Your stuff is here";
_vehicleMarker setMarkerColorLocal "ColorRed";
      };

} forEach _vehicle;

Share this post


Link to post
Share on other sites

Thanks austin_medic,

Worked like a charm and i learned that you need to restart the mission/local server from time to time =).

I actually had it like that but it just threw errors at me, guess that's what you get doing stuff other than sleep 4 in the morning.

Thanks again

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  

×