Jump to content
Sign in to follow this  
Drongo69

createMarkerLocal problem

Recommended Posts

In my command engine, I use markers created with the createMarkerLocal command to monitor friendly groups. In single player, it works fine. However, in coop (only 2-man) duplicates of each marker appear (slightly off center but overlapping each other). I have gone over the code several times to make sure I am not calling the same script twice, it seems to be fine. The script should only run on a player's machine.

Has anyone seen a similar problem before? Any ideas on how to fix it?

Here is the code for the relevant script:

_group = _this select 0;
if NOT(local player) exitWith {};
if NOT((side (leader _group)) == (side player)) exitWith {};
// To prevent markers from appearing for excluded groups, uncomment the following line
sleep 3;
_pos = [0,0];
_random = (random 99999999999);
_name = format ["%1%2%3",time,profileName,_random];
_marker = createMarkerLocal [_name,_pos];
//player globalChat _name;
_marker setMarkerPosLocal (getPos (leader _group));

_marker setMarkerSizeLocal [1,1];
_groupType = [_group] call dt_fnc_GroupType;
_markerType = [_groupType] call dt_fnc_MarkerType;
_marker setMarkerTypeLocal _markerType;
_markerName = [_group] call dt_fnc_TrimGroupName;
_marker setMarkerTextLocal _markerName;
_alive = true;
_count = 0;

while {(_alive)} do {
sleep 0.3;
_marker setMarkerColorLocal "ColorBlufor";
if (dtcSelectedGroup == _group) then {_marker setMarkerColorLocal "ColorGreen"};
_groupType = [_group] call dt_fnc_GroupType;
_pos = (getPos (leader _group));
if NOT(_groupType == "Mounted infantry") then {_marker setMarkerSizeLocal [1,1]; _marker setMarkerPos _pos};
if (_groupType == "Mounted infantry") then {_marker setMarkerSizeLocal [0.5,0.5]; _x = _pos select 0; _y = _pos select 1; _marker setMarkerPosLocal [_x,(_y + 5)]};
_alive = [_group] call dt_fnc_GroupisAlive;
_count = _count + 1;
if (_count > 100) then {_count = 0; _groupType = [_group] call dt_fnc_GroupType; _markerType = [_groupType] call dt_fnc_MarkerType; _marker setMarkerTypeLocal _markerType};
};
deleteMarkerLocal _marker;

That script is called from:

sleep 5;
_go = true;
_add = false;
_groups = [];
_men = [];
while {_go} do {
sleep 3;
_groups = allGroups;
while {((count _groups) > 0)} do {
	_group = _groups select 0;
	_groups = _groups - [_group];
	_add = true;
	// Add player and player groups to dtPlayers and dtPlayerGroups
	_men = [];
	_men = units _group;
	while {((count _men) > 0)} do {
		_man = _men select 0;
		_men = _men - [_man];
		if (isPlayer _man) then {
			dtPlayers = dtPlayers + [_man];
			if (NOT (_group in dtPlayerGroups)) then {dtPlayerGroups = dtPlayerGroups + [_group]; publicVariable "dtPlayerGroups"};
		};
	};
	if (_group in dtRegistered) then {_add = false};
	if (_group in dtExclusions) then {_add = false};
	if (_add) then {
		dtRegistered = dtRegistered + [_group];
		nul = [_group] execVM "DrongosToolkit\Scripts\Core\MonitorGroup.sqf";
		nul = [_group] execVM "DrongosToolkit\Scripts\Core\PrepareVehicles.sqf";
		if (dtUseMarkers) then {nul = [_group] execVM "DrongosToolkit\Scripts\Core\Marker.sqf"};
	};
};
};

Which is in turn called from the following script which is called from Init.sqf (the relevant line is right at the bottom in bold):

// Starts Drongo's Toolkit

// Should be called from init.sqf

// DO NOT EDIT THIS FILE. MAKE YOUR CHANGES IN Scripts\Preferences.sqf

sleep 1;

#include "\userconfig\DrongosToolkit\DTconfig.hpp"

dtReady = false;

dtDebug = false;

//dtDrongosArtilleryActive = false;

// Make sure the variable is defined as early as possible for DrongosToolkit\Scripts\Civs\SpawnerAdv.sqf

dtCivilians = false;

// Make sure the variable is defined as early as possible for DrongosToolkit\Scripts\Core\MonitorGroup.sqf

dtCached = [];

dtCacheExclusions = [];

//hint "Drongo's Toolkit v0.7\nMenu key: LEFT WINDOWS";

//dtKey = 0xDB;

findDisplay 46 displayAddEventHandler ["KeyDown", "if (_this select 1 == dtKey) then {null = [] execVM ""DrongosToolkit\Scripts\Core\ShowDialog.sqf""};"];

dtViewDistance = viewDistance;

_westHQ = createCenter West;

_eastHQ = createCenter East;

_resHQ = createCenter Resistance;

// Which dialog should the key default to?

dtCurrentDialog = "Personal";

// Array of items that are recognised as a radio (for commanding, enemy contact messages, etc)

dtRadioTypes = [];

dtRadioTypes = ["ItemRadio"];

// Units that can use the command dialog. If this is empty, anyone can use it.

dtCommanders = [];

// Used by the Command module, defined here as it is checked against in some non-Command scripts.

dtcGroups = [];

// Array of marker for use

dtMarkers = [];

_desiredNumberOfMarkers = 100;

// Use markers to mark groups?

dtUseMarkers = false;

dtAllGroups = [];

dtRegistered = [];

dtExclusions = [];

// For groups that are not available to command

dtcExcludedGroups = [];

dtSmokeGrenades = ["SmokeShellRed","SmokeShell","SmokeShellGreen","SmokeShellYellow","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];

dtTransmissionW = [];

dtTransmissionE = [];

dtTransmissionR = [];

dtEndMission = false;

// Array of players

dtPlayers = [];

// Array of player groups

dtPlayerGroups = [];

//dtDebug = true;

dtDebug = false;

dtCurrentDialog = "Personal";

// Array of items that are recognised as a radio (for commanding, enemy contact messages, etc)

dtRadioTypes = [];

dtRadioTypes = ["ItemRadio"];

// Units that can use the command dialog. If this is empty, anyone can use it.

dtCommanders = [];

// Array of vehicles that can be mounted as cargo (this is now set in DrongosToolkit\Scripts\Core\DefineTypes.sqf)

dtTransportTypes = [];

dtExcludedGroups = [];

// For groups that are not available to command

dtcExcludedGroups = [];

dtSmokeGrenades = ["SmokeShellRed","SmokeShell","SmokeShellGreen","SmokeShellYellow","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];

dtCommand = false;

dtCommand = true;

dtComms = false;

// Sounds with comms?

dtSound = true;

dtInfoShare = false;

dtObjectives = false;

dtAIcommander = false;

dtWeather = false;

dtCivilians = false;

dtSkill = false;

dtFunctionKeysActive = false;

//dtFunctionKeysActive = true;

if (dtCommand) then {dtUseMarkers = true};

// Camera mode for Command

dtcCameraIndex = 0;

dtcCameraOn = false;

// This is used for the Function Keys option. It requires description.ext in the mission root.

dtMissionRoot = call {

private "_arr";

_arr = toArray str missionConfigFile;

_arr resize (count _arr - 15);

toString _arr

};

nul = [] execVM "DrongosToolkit\Scripts\Core\DefineTypes.sqf";

nul = [] execVM "DrongosToolkit\Scripts\Core\Functions\LoadFunctions.sqf";

nul = [_desiredNumberOfMarkers] execVM "DrongosToolkit\Scripts\Core\PrepMarkers.sqf";

sleep 1;

nul = [] execVM "DrongosToolkit\Scripts\AiA\Start.sqf";

sleep 1;

nul = [] execVM "DrongosToolkit\Scripts\Core\RegisterGroups.sqf";

dtReady = true;

//hint "";

Edited by Drongo69

Share this post


Link to post
Share on other sites

Where and how do you call the script ?

Share this post


Link to post
Share on other sites

I added the relevant info to the first post to keep it all in one place.

Share this post


Link to post
Share on other sites

May or may not be a problem, or perhaps it copied funny, but your bolded line at the bottom has "sq f", not "sqf".

Edit: And just to be clear, is that last script called from init.sqf with isServer or anything, or are all machines running it?

Share this post


Link to post
Share on other sites

Dunno what's causing that, when I edit the post there is no space.

Share this post


Link to post
Share on other sites

if NOT(_groupType == "Mounted infantry") then {_marker setMarkerSizeLocal [1,1]; _marker setMarkerPos _pos};

should be

if NOT(_groupType == "Mounted infantry") then {_marker setMarkerSizeLocal [1,1]; _marker setMarkerPosLocal _pos};

I guess, so that it doesn't broadcast the marker globally.

Share this post


Link to post
Share on other sites

Good God, how did I miss that? I have been over and over the scripts and the entire system numerous times. I can't be sure until the next time I play coop, but that looks like it.

Thanks Conroy!

Share this post


Link to post
Share on other sites

Did that fix it?

It is interesting that a global command that simply edits a parameter broadcasts all parameters that were originally local.

Share this post


Link to post
Share on other sites

Any non-local marker command will always transmit all the markersettings.

It's possible to save a lot of bandwidth, when having some global markers, that frequently update, by using local commands, except for the very last one.

This for example only uses a fraction of the bandwidth compared to all commands being global, while having the same effect.

_marker setMarkerAlphaLocal 1;
_marker setMarkerTextLocal "";
_marker setMarkerTypeLocal "mil_dot";
_marker setmarkerColorLocal "ColorBlack";
_marker setmarkerDirLocal 0;
_marker setMarkerSizeLocal [1,1];
_marker setMarkerPos (getPosASL player);

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  

×