Jump to content
Sign in to follow this  
Jastreb

Hiddenselection rank image based on players ingame ( or editor assigned ) rank

Recommended Posts

Hello. I have a problem creating this and I need assistance. I am doing this for the upcoming mod release I work on.

Here it is. I have a model of a soldier, and he has a rank pallet on his chest. It is defined as hiddenselection called "rank".

What I want to do?

I have created rank images based on the Arma3 current ranking for my soldiers army. I can assign one of those images or make them random, but that is not what I want to achieve. I want predefined rank image to appear based on players ( or AI ) rank assigned in editor or the mission. It really needs to display players rank with proper image in hiddenselection named rank and update it if rank changes. It also needs to be JIP/respawn compatible.

I was thinking if AGM or Alive or MCC mods can do it with overhead rank image displayed, it can be done for this too. It just needs a bit of good scripting in which I am not that good to make something like this completely on my own.

Any ideas anyone will be very much appreciated.

Edited by _MaSSive
Changed topic title to be more descriptive

Share this post


Link to post
Share on other sites
_rank = rank player;
[player,call {
if (_rank == "PRIVATE") exitWith {"CfgUnitInsignia classname"};
if (_rank == "CORPORAL") exitWith {"CfgUnitInsignia classname"};
// ... etc
}] BIS_fnc_setUnitInsignia

Share this post


Link to post
Share on other sites

Wouldn't that set unit insignia on the insignia hiddenselection making my rank images to appear on the shoulder?

What I came up with is this

fnc_setUnitRankPrivate = 
{ 
	_unit = _this select 0;
	_index = 1;
	{
		if (_x == "rank") exitwith {_index = _foreachindex;};
	}	foreach getarray (configfile >> "CfgVehicles" >> gettext ( configfile >> "CfgWeapons" >> uniform _unit >> "ItemInfo" >> "uniformClass") >> "hiddenSelections");
	_unit setObjectTextureGlobal [_index, "\my_addon\rank\private.paa"];
};

fnc_setUnitRankCorporal = 
{ 
	_unit = _this select 0;
	_index = 1;
	{
		if (_x == "rank") exitwith {_index = _foreachindex;};
	}	foreach getarray (configfile >> "CfgVehicles" >> gettext ( configfile >> "CfgWeapons" >> uniform _unit >> "ItemInfo" >> "uniformClass") >> "hiddenSelections");
	_unit setObjectTextureGlobal [_index, "\my_addon\rank\corporal.paa"];
};

Where rank is a hiddenselection with index 1.

Then I do this

_rank = rank player;	
switch (_rank) do
{
	case "PRIVATE":
	{
		call fnc_setUnitRankPrivate;
	};
	case "CORPORAL":
	{
		call fnc_setUnitRankCorporal;
	};
};

I am not really sure if syntax is proper, haven't tried it yet, just tell me if I did anything stupid there, or will it work at all.

Edited by _MaSSive

Share this post


Link to post
Share on other sites

Bump.

Out of skype group where scripters mingle, I have got two workable solution a bit better formated and optimized.

The first one is solution by kylania

fnc_setUnitRank =
{
               _unit = _this select 0;
               _patch = _this select 1;
               _index = 1;
               {
                       if (_x == "rank") exitwith {_index = _foreachindex;};
               }       foreach getarray (configfile >> "CfgVehicles" >> gettext ( configfile >> "CfgWeapons" >> uniform _unit >> "ItemInfo" >> "uniformClass") >> "hiddenSelections");
               _unit setObjectTextureGlobal [_index, _patch];
};

_rank = rank player;   
       switch (_rank) do
       {
               case "PRIVATE":
               {
                       [player, "\\my_addon\rank\private.paa"] call fnc_setUnitRank;
               };
               case "CORPORAL":
               {
                       [player, "\\my_addon\rank\corporal.paa"]call fnc_setUnitRank;
               };
       };

The second one is from X39

//The function
fnc_setUnitRank = {
       private["_rank", "_unit", "_index", "_forEachIndex", "_x"];
       _rank = _this select 1;
       _unit = _this select 0;
       _index = -1;
       {
               scopeName "out";
               if (_x == "rank") exitWith
               {
                       _index = _forEachIndex;
                       breakOut "out";
               };
       } forEach getArray (configFile >> "CfgVehicles" >> getText ( configFile >> "CfgWeapons" >> uniform _unit >> "ItemInfo" >> "uniformClass") >> "hiddenSelections");
       _unit setObjectTextureGlobal [_index, format["\my_addon\rank\%1.paa", _rank]];
};
//The call
[player, rank player] call fnc_setUnitRank;

Still haven't tested, base model is not yet prepared, but here is the solution for anyone that wants a custom rank image to appear in the predefined hiddenselection on their model, automatically based on assigned rank in the editor or the MP session.

Many thanks to everyone involved. Once I test this I will update and post working solution.

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  

×