Jump to content
csk222

How to set markers on objects - alive players

Recommended Posts

Hello. I am getting an error when the blufor1_1, blufor1_2, and blufor1_3 slots are not filled by a player. I have looked into if, then, else, and exitwith but have not been able to come  up with the proper code. I would want it to not do anything (I've also looked into isnil).

		// Set up Markers On Leaders and Vehicles
		[] spawn
		{
			while {TRUE} do
			{
				sleep 5; // 10 original setting
				if (alive blufor1_1) then
				{
					"ofrsp" setMarkerPos position blufor1_1;
				};
				if (alive blufor1_2) then
				{
					"tlrsp" setMarkerPos position blufor1_2;
				};
				if (alive blufor1_3) then
				{
					"slrsp" setMarkerPos position blufor1_3;
				};				
			};
		};

Share this post


Link to post
Share on other sites

isNil should work. As variables assigned to object players which don't join from the begining are nil.

 

So:

if (!isNil "blufor1_1") then
{
   if (alive blufor1_1) then
   {
   "ofrsp" setMarkerPos position blufor1_1;
   };
}

should work.

Share this post


Link to post
Share on other sites

RPT:

23:55:47 Error in expression <kerPos position blufor1_1;
};
if (alive blufor1_2) then
{
"tlrsp" setMarkerPos p>
23:55:47   Error position: <blufor1_2) then
{
"tlrsp" setMarkerPos p>
23:55:47   Error Undefined variable in expression: blufor1_2
23:55:47 File mpmissions\__cur_mp.Altis\init.sqf, line 155

Share this post


Link to post
Share on other sites

I had tried that before and it didn't work. I just tried it again and it semi works. What's happening now is that: If I am blufor1_1 it works fine, but if I am blufor1_2 it assigns the blufor1_1 marker to blufor1_2. Why's that happening?

 

Note: Thanks for the soldier tracker suggestion. It is not what I need.

Share this post


Link to post
Share on other sites

_nul = [] spawn {

while { true } do {

sleep 5;

{

_unit = missionNamespace getVariable [ format[ "blufor1_%1", _x select 0 ], objNull ];

if ( !isNull _unit && { alive _unit } ) then {

( _x select 1 ) setMarkerPos getPos _unit;

};

}forEach [

[ 1, "ofrsp" ],

[ 2, "tlrsp" ],

[ 3, "slrsp" ]

];

};

};

So find the global variable blufor1_# or return objnull if it does not exist, if its not null then check if its alive, if so update marker.
  • Like 1

Share this post


Link to post
Share on other sites
Guest

This might sound stupid but why you don't use allPlayers ? You use a server sided function with global markers (or local markers broadcasted to each client)

while { true } do {
    {
          // Check if marker exists
         If ((getMarkerPos str _x) isEqualTo [0,0,0]) then {
              (str _x) createMarker [name _x, getPos _x];
         } else {
              (str _x) setMarkerPos (getPos _x);
         }
    } forEach allPlayers;
    sleep 0.5;
}
I wrote this code on my phone with my small mind so just take it as a non working exemple of what you can do. Btw it misses the part where you delete the marker if the player is disconnected (I bet you can do that with a EventHandler or a marker list)

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

×