Jump to content
Sign in to follow this  
fn_Quiksilver

[Code Snippet] Lightweight player icons

Recommended Posts

Posted this to the discord, thought it could be useful to post here as well

 

I maintain a more comprehensive "soldier tracker" script here:   

 

However a community member asked for a "super light weight" script to add to a mission, this is reasonably lightweight, little more than an example.

 

NOTE: This will only work from version 2.12 onward. Until then you will have to change a line

 

// 2.10 (current game version)
uiNamespace setVariable ['TAG_mapList',allGroups select {((side _x) isEqualTo playerSide}];

// 2.12+
uiNamespace setVariable ['TAG_mapList',groups playerSide];

 

 

// initPlayerLocal.sqf
TAG_mymapfunction = {
	params ['_map'];
	// Update data only every x seconds
	if (diag_tickTime > (uiNamespace getVariable ['TAG_mapListInterval',-1])) then {
		uiNamespace setVariable ['TAG_mapListInterval',diag_tickTime + 5];				// 5 seconds interval
		uiNamespace setVariable [														// cache side color incase side changes
			'TAG_mapListSideColor',
			([
				[0.7,0.6,0,0.5],
				[0.5,0,0,0.65],
				[0,0.3,0.6,0.65],
				[0,0.5,0,0.65],
				[0.4,0,0.5,0.65],
				[0.7,0.6,0,0.5]
			] # (([sideUnknown, east, west, independent, civilian, sideUnknown] find playerSide) max 0))
		];
		//uiNamespace setVariable ['TAG_mapList',groups playerSide];	// show groups OR    // this line will only work in arma 2.12+
		uiNamespace setVariable ['TAG_mapList',units playerSide];		// show units
	};
	// Icon color for players side
	_color = uiNamespace getVariable ['TAG_mapListSideColor',[1,1,1,0.5]];
	// Draw
	{
		//_leader = leader _x;		// show groups OR
		_leader = _x;				// show units
		_map drawIcon [
			'a3\ui_f\data\map\vehicleicons\iconMan_ca.paa',	// Default man icon
			_color,
			getPosWorldVisual _leader,
			22,
			22,
			getDirVisual _leader,
			(if (_x isEqualType objNull) then {['',(name _leader)] select (_leader isEqualTo (effectiveCommander (vehicle _leader)))} else {(groupId _x)}),
			1,
			0.035,
			'puristaMedium',
			'right'
		];
	} forEach (uiNamespace getVariable ['TAG_mapList',[]]);
};
((findDisplay 12) displayCtrl 51) ctrlRemoveAllEventHandlers 'Draw';			// Remove existing, for debug/dev
((findDisplay 12) displayctrl 51) ctrlAddEventHandler [							// Add new event
	'Draw',
	'call TAG_mymapfunction'
];

 

Feel free to suggest optimisations!

  • Like 3

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  

×