Jump to content
Skullfinger_NL

Markers scrip not working in MP (Following and Color coded)

Recommended Posts

Hello,

 

In short:

I want some markers to follow there "attached" unit and change color when the state of the player changes. When i test this in local MP it works, however when i test it on our dedicated server de markers snap back to there starting position and sometimes the color does not update at all. Im wondering if it has something to do with double while {} do loop (see codes below) and i dont know how to fix it. 

I've learnd some basic coding from and for Arma 3 mission making so i dont know all the in's and out's. My question is if its possible to make the code "server friendly" or if its possible at all.

 

 

Senario:

PvP senario 3 man (BLUEFOR) against 23 man (independent). Where the 3 guys have better gear and know there enemy's location.

The 23 man have some POI map markers only visible to them, the 3 man on the other hand see the location and state of the 23 man.

 

The 23 man all have unique namers aka Unit_1 etc. Together with 23 Dot markers with the variable "west_Unit1M" etc.

 

To make the map markers visible to only there side I found the following post. https://forums.bohemia.net/forums/topic/211668-markers-only-visible-to-one-side/

The code is in the Init.sqf of the mission folder.

 

Init.sqf:

[] spawn {
    while {!isDedicated} do {
        waitUntil {
            sleep 1;
            alive player
        };
        {
            _arr = _x splitstring "_";
            _pre = _arr select 0;
            if (_pre in ["west", "east", "GUER", "CIV"]) then {
                if (format["%1", side player] == _pre) then {
                    _x setMarkerAlphaLocal 1;
                } else {
                    _x setMarkerAlphaLocal 0;
                };
            };
        } count allMapMarkers;
    };
}; 

 

Now for the Bluefor guys i wanted them to see the "state" of the enemy with colored markers as shown below. Red = Alive Yellow = Unconscious and Green = Dead and it deletes the marker after 60sec.

Im wondering if the Update_Marker.sqf needs a [] Spawn { like the code in the Init but im not sure if i need to account for the _u and _m.

 

Init of unit named Unit_1: (next is Unit_2 with marker "west_Unit2M" etc.)

[this,"west_Unit1M"] execVM "Update_Marker.sqf";

Update_Marker.sqf:

 //Update marker color
_u = _this select 0;
_m = _this select 1;

while {alive _u} do {
    _result = incapacitatedState _u;
    if (_result == "UNCONSCIOUS") then {
        _m setMarkerColor "ColorYellow";
    } else {
        _m setMarkerColor "ColorRed";
        _m setMarkerPosLocal getPos _u;
    };
    sleep 1;
};
_m setMarkerColor "ColorGreen";
sleep 60;
deleteMarker _m;

 

I hope this makes sense and that someone can help me.

 

Kind regards,

 

Ben

 

edit: Someone from my comunity recommended the Soldier Tracker script https://forums.bohemia.net/forums/topic/173952-soldier-tracker-map-and-gps-icons/

But as far as i could see it only made Blufor markers for Bluefor units that only they could see. I could not find a way to make Bluefor markers that follow Bluefor units that are only visible to the Independant side.

 

Share this post


Link to post
Share on other sites

I did not follow your whole code but idk if u noticed that every setMarker... command has a local and a global variant.

If u set multiple attributes of a marker then you should use the local variant for all but the last attribute.

using any global variant will propagate all marker attributes to all other clients. Therefore u need to use it only for setting the last attribute. But this has to be done to ensure that all clients knoe bout the changes.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

First of all, in MP, if you don't want to share markers, you must make them local (createMarkerLocal) and only use local command (setMarkerColorLocal...) Anytime you give them a non-local command (setMarkerPos...) you make them non-local! So markers are shared. That can lead to unexpected behavior.
Simple test:

Spoiler

Two players, one hurt (damage > 0.3) at start. A repetitive radio alpha trigger
 


0 = thisTrigger spawn {
   deleteMarker "essai";
   _mk = createMarkerLocal ["essai", _this getPos [100 * sqrt random 1,random 360]];
   _mk setMarkerShapeLocal "ellipse";
   _mk setMarkerSizeLocal [50,50];
   _mk setMarkerBrushLocal "solid";
   _mk setMarkerColorLocal (["colorBlufor","colorYellow"] select (damage player >0.25))
};

Test multiple times.... colors are ok, positions are non correlated... nothing hurts so far.

Now change setMarkerSizeLocal for setMarkerSize (just that). The colors are skipped (black by default).
Now, rewrite setMarkerSizeLocal but change setMarkerColorLocal for setMarkerColor  ... The colors are not secured (can be blue or yellow independently of damages).

 


 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

First of all, in MP, if you don't want to share markers, you must make them local (createMarkerLocal) and only use local command (setMarkerColorLocal...) Anytime you give them a non-local command (setMarkerPos...) you make them non-local! So markers are shared. That can lead to unexpected behavior.
Simple test:

  Reveal hidden contents

Two players, one hurt (damage > 0.3) at start. A repetitive radio alpha trigger
 



0 = thisTrigger spawn {
   deleteMarker "essai";
   _mk = createMarkerLocal ["essai", _this getPos [100 * sqrt random 1,random 360]];
   _mk setMarkerShapeLocal "ellipse";
   _mk setMarkerSizeLocal [50,50];
   _mk setMarkerBrushLocal "solid";
   _mk setMarkerColorLocal (["colorBlufor","colorYellow"] select (damage player >0.25))
};

Test multiple times.... colors are ok, positions are non correlated... nothing hurts so far.

Now change setMarkerSizeLocal for setMarkerSize (just that). The colors are skipped (black by default).
Now, rewrite setMarkerSizeLocal but change setMarkerColorLocal for setMarkerColor  ... The colors are not secured (can be blue or yellow independently of damages).

 


 

I get is so don't mix (setMarker) commands with (setMarkerLocal) commands in the same script. it messes with everything for that marker.

I removed the local in (setMarkerPosLocal) to make it global. Also i removed the pre existing markers and added a (createMarker).

 

The markers need to be global because the script in the init does the "sorting" so to speak.

After some quick testing its working like i intented it in the first place!

I think i've been staring at the wrong section of the code.

 

Thanks!


The updated tested and working "Update_Marker.sqf"

// Update marker color
_u = _this select 0;
_m = _this select 1;
_markerstr = createMarker [_m,_u];
_markerstr setMarkerType "mil_dot";
_markerstr setMarkerAlpha 0;

while {alive _u} do {
    _result = incapacitatedState _u;
    if (_result == "UNCONSCIOUS") then {
        _m setMarkerColor "ColorYellow";
    } else {
        _m setMarkerColor "ColorRed";
        _m setMarkerPos getPos _u;
    };
    sleep 1;
};
_m setMarkerColor "ColorGreen";
sleep 60;
deleteMarker _m;

 

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

×