Jump to content
Sign in to follow this  
iceman77

group markers

Recommended Posts

Iv'e made a group marker script for a coop map.It's called like this from each playable character initline: null = [unitname, "mkrName"] execVM "team_markers.sqf";

I should probably compile PreprocessFile and spawn this script iam assuming, but for testing i used execVM (dont ask why...) :idea: :638:

team_markers.sqf

waitUntil { !isNull player }; 
waitUntil { player == player };

private ["_unit","_mkrname"];

_unit = _this select 0;
_mkrname = _this select 1;

_mkrName = createMarker [_mkrname, position _unit];
_mkrname setMarkerType "man";
_mkrname setMarkerColor "Colorgreen";
_mkrname setMarkerSize [0.6,0.6];
_mkrname setMarkerText Name _unit;

    while {alive _unit} do 

     {

       sleep 0.5;

       _mkrName setMarkerPos getpos _unit;

     };

deleteMarker _mkrname;
_mkrname = Nil;

sleep 13;

switch (player) do

    {
        case s1:

        {
          this = [s1, "s1m"] execVM "scripts\Team_Markers.sqf";
        };

        case s2:

        {
          this = [s2, "s2m"] execVM "scripts\Team_Markers.sqf";
        };

        case s3:

        {
          this = [s3, "s3m"] execVM "scripts\Team_Markers.sqf";
        };

        case s4:

        {
          this = [s4, "s4m"] execVM "scripts\Team_Markers.sqf";
        };

        case s5:

        {
          this = [s5, "s5m"] execVM "scripts\Team_Markers.sqf";
        };

        case s6:

        {
          this = [s6, "s6m"] execVM "scripts\Team_Markers.sqf";
        };

        case s7:

        {
          this = [s7, "s7m"] execVM "scripts\Team_Markers.sqf";
        };

        case s8:

        {
          this = [s8, "s8m"] execVM "scripts\Team_Markers.sqf";
        };

        case s9:

        {
          this = [s9, "s9m"] execVM "scripts\Team_Markers.sqf";
        };

        case s10:

        {
          this = [s10, "s10m"] execVM "scripts\Team_Markers.sqf";
        };

        case s11:

        {
          this = [s11, "s11m"] execVM "scripts\Team_Markers.sqf";
        };

        case s12:

        {
          this = [s12, "s12m"] execVM "scripts\Team_Markers.sqf";
        };


    };

It works fine when I test it on a dedicated server, the marker shows up initially and on respawn.When I leave the server and jip back to a diffrent slot, the marker still works fine... though I get an ERROR message upon jip.Why? and how can i fix this?

RPT shows:


Error in expression <_mkrname = _this select 1;
_mkrName = createMarker [_mkrname, position _unit];>
 Error position: <createMarker [_mkrname, position _unit];>
 Error 0 elements provided, 3 expected
File mpmissions\__CUR_MP.Chernarus\scripts\team_Markers.sqf, line 11
WARNING: Function 'name' - s2 has no unit

Share this post


Link to post
Share on other sites

I've not done any MP so Error 0 elements provided, 3 expected would mean that no unit name has been passed.

I see the game waits 13 seconds before starting the script again after a unit dies but what happens if it takes longer than that to get back into the game, the script will run but without a player.

The other thing is that could be happening is that the script may be being called twice.

Once in the players init and again in the script.

I'd try placing a waitUntil { player == player }; instead of sleep 13 or even removing all the switch case stuff.

As I said I've not done any MP but I'd look at those things first.

Share this post


Link to post
Share on other sites

This is what i use in my MP missions and works fine, maybe can help you :)

In the init.sqf:

players_string        = ["s1","s2","s3","s4","s5","s6","s7","s8","s9","s10","s11","s12","s13","s14","s15","s16","s17"];
{_marker = createmarkerLocal [_x, [0,0]];_x setmarkertypelocal "Man";_x setmarkerColorlocal "ColorBlue";_x setMarkerSizeLocal [0.7, 0.7];} foreach players_string;

BTC_Marker =
{
{
	if (Alive _x && isplayer _x) then
	{
		if (leader _x == _x) then
		{
			format ["%1", group _x] setMarkerPosLocal (getpos _x);
			format ["%1", group _x] setMarkerTextLocal format ["%1 (%2)", group _x, name _x];
			if (group _x == group player) then {format ["%1", group _x] setMarkerColorLocal "ColorGreen";} else {format ["%1", group _x] setMarkerColorLocal "ColorBlue";};
		}
		else
		{
			format ["%1", _x] setMarkerPosLocal (getpos _x);
			format ["%1", _x] setMarkerTextLocal format ["%1", name _x];
			if (group _x == group player) then {format ["%1", _x] setMarkerColorLocal "ColorGreen";} else {format ["%1", group _x] setMarkerColorLocal "ColorBlue";};
		};
	}
	else
	{
		format ["%1", _x] setMarkerPosLocal [0,0];
		format ["%1", _x] setMarkerTextLocal "";
	};
} foreach [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17];
};
true

If you have a main client loop just add this line:

[] call BTC_Marker;

Or you can modify the script and add this line at the end with a sleep.

Obviously you have to modify the playable units in the array ;)

Share this post


Link to post
Share on other sites

This should work for your purpose and be JIP compatible and low stress.

Only tested in MP editor btw.

Place in init.sqf

player execVM "trackMarker.sqf";

save this as trackMarker.sqf

waitUntil {!isNull _this};
if (_this != player OR !isNil "trackingPlayerMarkers") exitWith {};
trackingPlayerMarkers = true;  // not sure if this is really needed, combined with the OR part above.

_marker_fnc = {
_mkrNr = _this select 0;
_unit = _this select 1;
_mkrName = format["playerMarker_%1",_mkrNr];
_mkr = createMarkerLocal [_mkrName, position _unit];
_mkr setMarkerTypeLocal "man";
_mkr setMarkerColorLocal "Colorgreen";
_mkr setMarkerSizeLocal [0.6,0.6];
_mkr setMarkerTextLocal Name _unit;
_mkr
};

_mrkNr = 0;
_mrkArr = [];
while {true} do {
{
	_unit = _x;
	if ( ({_unit in _x} count _mrkArr) == 0 ) then {
		_mrkNr = _mrkNr + 1;
		_mkr = [_mrkNr,_unit] call _marker_fnc;
		_mrkArr = _mrkArr + [[_unit,_mkr]];
	};
} foreach playableUnits;

_cnt = 0;
{
	_unit = _x select 0;
	_mkr = _x select 1;
	if (!isNull _unit) then {
		_mkr setMarkerPos (getpos _unit);
	} else {
		deleteMarker _mkr;
		_mkr = Nil;
		_mrkArr set [_cnt,-1];
		_mrkArr = _mrkArr - [-1];
	};
	_cnt = _cnt + 1;
} foreach _mrkArr;
sleep 0.5;
};

Edited by Demonized
added player double run protection, maybe not needed.

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  

×