diff --git a/f/FTMemberMarkers/f_localFTMemberMarker.sqf b/f/FTMemberMarkers/f_localFTMemberMarker.sqf index 2a63ade3..6b727fa5 100644 --- a/f/FTMemberMarkers/f_localFTMemberMarker.sqf +++ b/f/FTMemberMarkers/f_localFTMemberMarker.sqf @@ -54,7 +54,7 @@ while{alive _unit && (_unit in f_var_HandlerGroup)} do _mkr setMarkerDirLocal _dir; // makes a call to the function defined in f_setLocalFTMemberMarkers.sqf // retreives the stored color from the unit. - _mkr setMarkerColorLocal (_unit getvariable ["assignedTeam","ColorWhite"]); + _mkr setMarkerColorLocal ([_unit] call f_fnc_GetUpdatedTeamValue); } else { f_var_HandlerGroup = f_var_HandlerGroup - [_unit]; }; diff --git a/f/FTMemberMarkers/fn_LocalFTMarkerSync.sqf b/f/FTMemberMarkers/fn_LocalFTMarkerSync.sqf deleted file mode 100644 index 5171796e..00000000 --- a/f/FTMemberMarkers/fn_LocalFTMarkerSync.sqf +++ /dev/null @@ -1,51 +0,0 @@ -// F3 - Fireteam Marker Team Color Synchronization -// Credits: Please see the F3 online manual (http://www.ferstaberinde.com/f3/en/) -// Description: Sync the groups teamcolors to other players in the group. -// Parameters -// 0: Group -// 1: Unit -// Returns: -// Nothing -// Example: -// [grp,unit] call f_fnc_LocalFTMarkerSync; -// -// ==================================================================================== - -private ["_colorTeam"]; -params["_grp", "_unit"]; - -// ==================================================================================== - -// BEGIN SYNCHRONIZATION -// if he is still alive and groupLeader - -while{_unit == (leader _grp) && alive _unit} do -{ - { - // if unit in my group is alive lets check his teamColor - if(alive _x) then - { - _colorTeam = [assignedTeam _x] call f_fnc_GetMarkerColor; - // if _colorTeam is not equal to whatever is set on the unit we must update the other units in the group - if((_x getvariable ["assignedTeam","ColorWhite"]) != _colorTeam) then - { - // debug messages - if (f_param_debugMode == 1) then {player sidechat format["%1 ---- %2 by %3",(_x getvariable ["assignedTeam","ColorWhite"]) ,_colorTeam,_unit];}; - - // sends a call to each unit in the group to use the local with the [x_colorTeam] as args. - [_x,_colorTeam] remoteExec ["f_fnc_SetTeamValue", _grp]; - }; - }; - - } foreach units _grp; - sleep 3; -}; - -// if the group is not gone. -if(!isnil "_grp") then -{ - // get the new leader - private _leader = leader _grp; - // tell him to start running the sync. - [_grp,_leader] remoteExec ["f_fnc_LocalFTMarkerSync", _leader]; -}; diff --git a/f/FTMemberMarkers/fn_SetLocalFTMemberMarkers.sqf b/f/FTMemberMarkers/fn_SetLocalFTMemberMarkers.sqf index c176c0da..91bd80cc 100644 --- a/f/FTMemberMarkers/fn_SetLocalFTMemberMarkers.sqf +++ b/f/FTMemberMarkers/fn_SetLocalFTMemberMarkers.sqf @@ -10,6 +10,8 @@ // // ==================================================================================== +if (!hasInterface) exitWith {}; + // MAKE SURE THE PLAYER INITIALIZES PROPERLY if (!isDedicated && (isNull player)) then { @@ -19,14 +21,29 @@ if (!isDedicated && (isNull player)) then // ==================================================================================== // DEFINE HELPER-FUNCTION -// Define a small function to set a unit's team color +// Define a small function to get/set a unit's team color +// This function updates the assignedTeam variable +// if assignedTeam returns a new team(color). -f_fnc_SetTeamValue = +f_fnc_GetUpdatedTeamValue = { - params["_unit", "_color"]; - _unit setvariable ["assignedTeam",_color]; + params["_unit"]; + private _team = assignedTeam _unit; + private _color = _unit getvariable ["assignedTeam","ColorWhite"]; + //_team can be nil if the player is controlling another unit (uav, zeus). + if(!isNil "_team") then + { + private _colorNew = [_team] call f_fnc_GetMarkerColor; + if(_color != _colorNew) then + { + _unit setVariable ["assignedTeam",_colorNew]; + _color = _colorNew; + }; + }; + _color }; + // ==================================================================================== // START DRAWING MARKERS @@ -47,13 +64,3 @@ f_fnc_SetTeamValue = sleep 5; }; }; - -// ==================================================================================== - -// SYNCHRONIZE TEAM COLORS -// If the player is the groupleader he will take charge of updateing the other units of the colorvalue. - -if(player == leader (group player)) then -{ - [group player,player] spawn f_fnc_LocalFTMarkerSync; -}; diff --git a/f/functions.hpp b/f/functions.hpp index 6c540d60..7437eac3 100644 --- a/f/functions.hpp +++ b/f/functions.hpp @@ -55,7 +55,6 @@ class F // Defines the "owner" file = "f\FTMemberMarkers"; class SetLocalFTMemberMarkers{}; class GetMarkerColor{}; - class LocalFTMarkerSync{}; }; class bodyRemoval {