Jump to content
Sign in to follow this  
KaRRiLLioN

Issues with Markers in a squadmarker script

Recommended Posts

I've been staring at this so long, my eyes are gonna bleed.  Here's the issue.  This squadmarker script creates a marker for each string in an array and then tracks the marker for each person on your team.  Obviously it's only supposed to track your team.

Since createMarker is Global and all other Marker commands appear to be Local, it seems this should work.  When I join a dedicated server and play the mission and leave on all AI, then I only see my team's markers.  But if another player joins the opposing team, suddenly, all markers are visible to each team.  I can't figure it out!

It works as it should locally on my PC and also on the dedicated UNTIL another player connects.  If anyone can point out what could cause this, I'd be immensely grateful.

Here's the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private ["_run","_wMarkers","_eMarkers","_rMarkers","_x"];

_wMarkers = ["W1","W2","W3","W4","W5","W6","W7","W8","W9","W10","W11","W12","W13","W14","W15","W16"];

_eMarkers = ["E1","E2","E3","E4","E5","E6","E7","E8","E9","E10","E11","E12","E13","E14","E15","E16"];

_rMarkers = ["R1","R2","R3","R4","R5","R6","R7","R8","R9","R10","R11","R12"];

_markerType = "SELECT";

_markerList = [];

if (SIDE Player == WEST) then {_markerList = _wMarkers};

if (SIDE Player == EAST) then {_markerList = _eMarkers};

if (SIDE Player == GUER) then {_markerList = _rMarkers};

if (!(SIDE Player in [WEST,EAST,GUER])) then {_markerList =[]};

//Local Server creates all Markers so it gets all arrays

if (Local Server && !Local Player) then {_markerList = _wMarkers + _eMarkers + _rMarkers};

_x = 0;

player groupChat format ["Markers: %1",_markerList];

while {_x < (count _markerList)} do

{

sleep .02;

_string = _markerList select _x;

_marker = format ["Marker%1",_string];

_color = call compile format ["Color%1", SIDE Player];

//Local Server only creates all Markers

if (Local Server) then {createMarker [_marker, getPos Server]};

_marker setMarkerShape "ICON";

_marker setMarkerType _markerType;

_x = _x + 1;

};

_x = 0;

_y = 0;

_run = TRUE;

//Local server should exit and only players from here on

if (!Local Player) exitWith {Hint "Exiting"};

//loop nests so it doesn't exit after 10,000 loops.

_i = 0;

while {(_i < 9999)} do

{

  _j = 0;

  while {(_j < 9999)} do

  {

      _k = 0;

      while {(_k < 9999)} do

      {

while {_run} do

{

sleep .001;

_string = _markerlist Select _x;

_unit = call compile _string;

_color = call compile format ["Color%1", SIDE _unit];

           //this should only allow markers for teammates to be visible.

if (Alive _unit && SIDE _unit == SIDE Player) then

{

_marker = format ["Marker%1",_string];

if (isPlayer _unit) then {_marker setMarkerColor _color} else {_marker setMarkerColor "ColorWhite"};

_marker setMarkerShape "ICON";

_marker setMarkerSize [.5,.5];

_marker setMarkerText format ["%1  %2",_string,Name _unit];

_marker SetMarkerType _markerType;

_marker SetMarkerPos GetPos Call compile _string;

}

else {_marker SetMarkerType "EMPTY"};

_x = _x + 1;

if (_x > Count _markerList) then {_x = 0};

};

          _k = __k + 1;

      };

      _j = _j + 1;

  };

  _i = _i + 1;

};

Share this post


Link to post
Share on other sites

After mucking around, pulling my hair out and killing several of god's gentle creatures, I think I found out why this is happening.

When you setMarkerText, the marker suddenly becomes visible to everyone.  I tested on a dedicated server by creating a marker locally.  I then set Size, color, type and the marker remained visible only to me.  Then I setMarkerText to "Hello" and voila!  Everyone could see it.

So all my wonderful plans for putting people's names on their markers is not going to work.  Unless there's some simple solution.

Here's an SQS version of my script, which actually looks much cleaner than the SQF version, thanks to all that nesting to beat the 10K loop limit.  This one doesn't create the markers because I was eliminating possibilities for the issue.  I'll reimplement the createMarker part then do everything but setMarkerText for now, I guess.

The reason my old one seemed to work properly until another player joined the other team is because the Local Server only creates the markers, but the player script sets the marker text.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_wMarkers = ["W1","W2","W3","W4","W5","W6","W7","W8","W9","W10","W11","W12","W13","W14","W15","W16"]

_eMarkers = ["E1","E2","E3","E4","E5","E6","E7","E8","E9","E10","E11","E12","E13","E14","E15","E16"]

_rMarkers = ["R1","R2","R3","R4","R5","R6","R7","R8","R9","R10","R11","R12"]

#MarkerTracker

_markerType = "SELECT"

?(SIDE Player == WEST) : _markerList = _wMarkers

?(SIDE Player == EAST) : _markerList = _eMarkers

?(SIDE Player == RESISTANCE) : _markerList = _rMarkers

?SIDE Player in [WEST,EAST,RESISTANCE] : Goto "Track"

Exit

#Track

_x = 0

#TrackLoop

~.01

_string = _markerlist Select _x

_unit = call compile _string

?Alive Call compile _string : Goto "Mpos"

_string SetMarkerType "EMPTY"

Goto "Skip"

#MPos

_string SetMarkerType _markerType

_string SetMarkerPos GetPos Call compile _string

_string setMarkerText format ["%1  %2",_string,Name _unit];

_string setMarkerSize [.5,.5]

#Skip

_x = _x + 1

?(_x > Count _markerList) : _x = 0

Goto "TrackLoop"

Share this post


Link to post
Share on other sites

Will take a look at the functions aswell soon, just a hint... you can drop the _j, _i etc. countings and just make while {true} do loops in eachother:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {true} do

{

  while {true} do

  {

  };

};etc.. makes it already a lil cleaner m8 smile_o.gif (You can excange true for _run etc again)

Oh and if yu replace ur tabs with 4 spaces when copying to the forum, it's easier to read aswell biggrin_o.gif

update:

Did you try creating the markers on the fly, as they only get created locally then, afaik? createMarker

Share this post


Link to post
Share on other sites

As noted in my first post, yes I used createMarker, which, BTW, is Global not Local. And as noted in my second post, I discovered setMarkerText is also Global.

That was the problem. Since I can't setMarkerText locally, I'm just pre-placing markers again since I can't set any text to them or the stupid things will show up again.

Also, I'm sticking with an SQS for this now since the function is messier and the SQS works just fine and is cleaner. For my CTF scripts I went to SQF.

Since I script everything in notepad, I can't be arsed to format the entire bloody thing for the forum. It takes longer to hit space several times for indenting when I'm scripting instead of hitting tab.

Share this post


Link to post
Share on other sites
...

ty for the answer, sorry that I missed the createmarker stuff..

What I meant was doing a search replace tabs with 4 spaces when you copy it to the forum wink_o.gif Suggestion anyway, happy new year btw smile_o.gif

Btw.. after you setmarker text, what happens when you change the markertype on one of the clients, is it global then aswell? If not, you might put the markers on type empty on the other clients smile_o.gif

Share this post


Link to post
Share on other sites

I've thought of that, but there's a timing issue involved that might still allow the other markers to blip on. I'll have to patch around it. I think I figured out how, just need to implement it.

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  

×