Jump to content
Garmrr

RHS ACU nametags script

Recommended Posts

Hello all!

I recently made a mission where depending on a players UID they get assigned a certain nametag for the RHS:USAF ACU uniform for the UCP and upcoming OEF-CP uniform (currently available on dev branch).
I figured this might be something other units or people are interested in, hence I decided to post my method right here!

 

initPlayerLocal.sqf

Spoiler

[] execVM "Path\to\nametags.sqf";

 

 

onPlayerRespawn.sqf

Spoiler

[] execVM "Path\to\nametags.sqf";

 


nametags.sqf

Spoiler

// Assign nametags upon loading into teh mission and respawning.
if (uniform player == "rhs_uniform_acu_ucp") then // If player has UCP ACU
	{
    	_uid = getPlayerUID player;
		if (getPlayerUID player == "PlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\nametag.paa"]};
		if (getPlayerUID player == "OtherPlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\other\nametag.paa"]};
	};
	if (uniform player == "rhs_uniform_acu_oefcp") then // If player has OEF-CP ACU
	{
    	_uid = getPlayerUID player;
		if (getPlayerUID player == "PlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\nametag.paa"]};
		if (getPlayerUID player == "OtherPlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\other\nametag.paa"]};
	};


// Assign nametags upon closing ACE Arsenal
["ace_arsenal_displayClosed", 
{
	if (uniform player == "rhs_uniform_acu_ucp") then // If player has UCP ACU
	{
    	_uid = getPlayerUID player;
		if (getPlayerUID player == "PlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\nametag.paa"]};
		if (getPlayerUID player == "OtherPlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\other\nametag.paa"]};
	};
	if (uniform player == "rhs_uniform_acu_oefcp") then // If player has OEF-CP ACU
	{
    	_uid = getPlayerUID player;
		if (getPlayerUID player == "PlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\nametag.paa"]};
		if (getPlayerUID player == "OtherPlayerUIDHere") then {player setObjectTextureGlobal [3,"Path\to\other\nametag.paa"]};
	};
}] call CBA_fnc_addEventHandler;

 

 

Here are the .psd files I use for the nametags, I find these give the most similar background to match the rest of the uniform:
.psd templates

Note that if you are unsure of wheteher your name fits the nametags you can drag the "UVs" layer above the name layer.

The guides are there to show the outline and center of the rank patch.

Best regards,
OPSEC

Edited by Garmrr
Clarification
  • Thanks 1

Share this post


Link to post
Share on other sites

Why do you set the texture twice every time? also this can be simplified:

//in initplayerLocal.sqf 
TAG_fnc_playerData ={
	params ["_player"];
	private _UIDsTexts = 
	[
		["SOMEPLAYERUID","PATHTOCORRESPONDINGTEXT"],
		["SOMEOTHERPLAYERUID","SOMEOTHERPATHTOTEXT"]	//etc
	];
	private _return = [];
	{
		if (getPlayerUID _player == (_x select 0)) then {_return =_x};
	}forEach _UIDsTexts;
	_return

};


TAG_fnc_setNameTag = {
	params ["_player"];
	private _data = [_player] call TAG_fnc_playerData;
	if (_data isEqualTo []) exitWith {diag_log format ["Player %1 not listed",name _player],false};
	if ((uniform _player) in ["rhs_uniform_acu_ucp","rhs_uniform_acu_oefcp"]) then 
	{
		_player setObjectTextureGlobal [3,(_data select 1)];
	};
	true
};
//------
[player] call TAG_fnc_setNameTag;

["ace_arsenal_displayClosed", 
{
	[player] call TAG_fnc_setNameTag;
}] call CBA_fnc_addEventHandler;


 

Share this post


Link to post
Share on other sites
1 hour ago, Mr H. said:

Why do you set the texture twice every time? also this can be simplified:

Answering my own question: you did that because you have one texture for oefcp one for ucp but you don't need that, when texture with color alpha (transparent background) works fine, just tested it, and saves you the trouble of having to prepare two textures for players. Aso I've modified the script again. The uniform with nametag space has a selection called "identity", the following will work with all uniforms having a selection "identity" if rhs keeps this structure it will be compatible with all the uniforms that support it. This has been tested and works:
 

//in initplayerLocal.sqf 
TAG_fnc_playerData ={
	params ["_player"];
	private _UIDsTexts = 
	[
		["SOMEPLAYERUID","PATHTOCORRESPONDINGTEXT"],
		["SOMEOTHERPLAYERUID","SOMEOTHERPATHTOTEXT"]	//etc
	];
	private _return = [];
	{
		if (getPlayerUID _player == (_x select 0)) then {_return =_x};
	}forEach _UIDsTexts;
	_return

};


TAG_fnc_setNameTag = {
	params ["_player"];
	private _data = [_player] call TAG_fnc_playerData;
	if (_data isEqualTo []) exitWith {diag_log format ["Player %1 not listed",name _player],false};
	if ("identity" in (selectionNames _player)) then 
	{
		_player setObjectTextureGlobal [3,(_data select 1)];
	};
	true
};
//------
[player] call TAG_fnc_setNameTag;

["ace_arsenal_displayClosed", 
{
	[player] call TAG_fnc_setNameTag;
}] call CBA_fnc_addEventHandler;

 

Share this post


Link to post
Share on other sites
2 hours ago, Mr H. said:

Answering my own question: you did that because you have one texture for oefcp one for ucp but you don't need that, when texture with color alpha (transparent background) works fine, just tested it, and saves you the trouble of having to prepare two textures for players. Aso I've modified the script again. The uniform with nametag space has a selection called "identity", the following will work with all uniforms having a selection "identity" if rhs keeps this structure it will be compatible with all the uniforms that support it. This has been tested and works:
 


//in initplayerLocal.sqf 
TAG_fnc_playerData ={
	params ["_player"];
	private _UIDsTexts = 
	[
		["SOMEPLAYERUID","PATHTOCORRESPONDINGTEXT"],
		["SOMEOTHERPLAYERUID","SOMEOTHERPATHTOTEXT"]	//etc
	];
	private _return = [];
	{
		if (getPlayerUID _player == (_x select 0)) then {_return =_x};
	}forEach _UIDsTexts;
	_return

};


TAG_fnc_setNameTag = {
	params ["_player"];
	private _data = [_player] call TAG_fnc_playerData;
	if (_data isEqualTo []) exitWith {diag_log format ["Player %1 not listed",name _player],false};
	if ("identity" in (selectionNames _player)) then 
	{
		_player setObjectTextureGlobal [3,(_data select 1)];
	};
	true
};
//------
[player] call TAG_fnc_setNameTag;

["ace_arsenal_displayClosed", 
{
	[player] call TAG_fnc_setNameTag;
}] call CBA_fnc_addEventHandler;

 

 

I'm still very new to scripting with sqf, that's why I did it this way. There are probably a million better ways of making this work but I am too incompetent to figure out those ways.
Also, there are two lines with the same text because it's supposed to be two different UID's, sorry for not clarifying that.

  • Sad 1

Share this post


Link to post
Share on other sites

Don't say that! Your script was good in the first place, when you post here people will offer alternatives and more optimized versions, I'm sure someone here can do better than my solution as well! That's how you learn. This was in no way meant as criticism!

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Mr H. said:

I'm sure someone here can do better than my solution as well!

🤔

TAG_fnc_playerData ={
	params ["_player"];
	private _UIDsTexts = 
	[
		["SOMEPLAYERUID","PATHTOCORRESPONDINGTEXT"],
		["SOMEOTHERPLAYERUID","SOMEOTHERPATHTOTEXT"]	//etc
	];
	private _playerUID = getPlayerUID _player;
	private _dataIndex = _UIDsTexts findIf {(_x select 0) == _playerUID};
	_UIDsTexts param [_dataIndex, []]
};

:yay:

  • Like 1

Share this post


Link to post
Share on other sites

ah ah  yeah I don't use findIf often enough! 😊

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

×