Jump to content
pierremgi

BIS_fnc_getUnitInsignia... sometimes

Recommended Posts

Hello,

I can't understand what I'm missing, trying to display insignia for a SP mission, even after changing uniform.

 

This works fine:

{
  _x spawn {
    _unit = _this;
    while {true} do {
        [_unit,"GBGM"] call BIS_fnc_setUnitInsignia;
      sleep 3;
    };
  }
} forEach units GBGM;

This doesn't work on uniform shift !!!:

{
  _x spawn {
    _unit = _this;
    while {true} do {
       waitUntil {sleep 3; [_unit] call BIS_fnc_getUnitInsignia != "GBGM"};
       [_unit,"GBGM"] call BIS_fnc_setUnitInsignia;
    };
  }
} forEach units GBGM;

All units in group GBGM receive the insignia at start but never more after that. As player, if you change uniform, or just drop/take yours, the insignia disappear but debug console says you have it (returns true for the same condition as in waitUntil)...

 

In fact Bis_fnc_getUnitInsignia doesn't report the current insignia but the set one, even if no more displayed.

Share this post


Link to post
Share on other sites

Yes, but all is fine in the description.ext and the display as far as player doesn't change his uniform.

 

In fact, this poor function (Bis_fnc_getUnitInsignia) is just returning the insignia you called via bis_fnc_SetUnitInsignia.

As, usually, Arma is quick at loosing insignia when player changes his uniform, this function sucks.

 

I'm about to catch a solution:

{
  _x spawn {
    _unit = _this;
    _uniform = uniformContainer _this;
    while {true} do {
      [_unit,"GBGM"] call BIS_fnc_setUnitInsignia;
       waitUntil {sleep 3; uniformContainer _unit != _uniform};
       _uniform = uniformContainer _unit;
    };
  }
} forEach units GBGM;

At least you can retrieve the insignia each time something changes with the uniform. (uniformContainer is better than uniform in case of player grabs the same uniform from a crate).

 

Now, I'm looking for a persistent code for MP...

Share this post


Link to post
Share on other sites

It's a custom patch for anyone playing my mission, not a nth addon. So, it's in description.ext (paa is in the mission folder):

class CfgUnitInsignia
{
  class GBGM
  {
    displayName = "Groupement Blindé Gendarmerie Mobile"; 
    author = "Pierre MGI"; 
    texture = "logoGend.paa"; 
    textureVehicle = ""; 
  };
};

The mission is SP/MP, SP comes with switchable units (who give some stuffs with addAction and other non-persistent behavior).

 

So, if I want to make everything clear (insignia always displayed for player(s)/AIs group, I need to add:

 

in initServer.sqf :

{
  _x spawn {
    _unit = _this;
    _uniform = uniformContainer _this;
    while {true} do {
      [[_unit,"GBGM"] , BIS_fnc_setUnitInsignia] remoteExec ["call",0,true];
       waitUntil {sleep 3; uniformContainer _unit != _uniform};
       _uniform = uniformContainer _unit;
    };
  }
} forEach units GBGM;

in initPlayerLocal.sqf :

player addEventHandler ["Respawn", {player spawn {
    _unit = _this;
    _uniform = uniformContainer _this;
    while {alive player} do {
      [[_unit,"GBGM"] , BIS_fnc_setUnitInsignia] remoteExec ["call",0,true];
       waitUntil {sleep 3; uniformContainer _unit != _uniform};
       _uniform = uniformContainer _unit;
   }};
  }
];

There are probably smarter solutions...  I do what I can with my understanding of BI documentation. I was just missing the fact Bis_fnc_getUnitInsignia, even called at the right place, just returns the set insignia, not the actual (wysiswyg, on the shoulder) one.

Share this post


Link to post
Share on other sites

Bah, BIS_fnc_setUnitInsignia is broken with setObjectTextureGlobal in it.

 

I didn't success to make that work in MP....

Share this post


Link to post
Share on other sites

You also have no link to the custom texture in any of your configs.

Share this post


Link to post
Share on other sites

Could you explain? What link? the paa is found in SP, found in MP for hosted server. So, what can I do if client must have a different "link"?

Share this post


Link to post
Share on other sites

It's a custom patch, so it will have needed to have a config.cpp for it to work, within that config.cpp you should have a link to where the custom patch is located, and it's associated texture.

 

class CfgUnitInsignia
{
  class GBGM
 
{
    displayName = "Groupement Blindé Gendarmerie Mobile";
    author = "Pierre MGI";
    texture = "logoGend.paa";
    textureVehicle = "";
  };
};

 

 

 

 

the bold part needs to have the path to the texture, as in where is the texture in your addon, otherwise it will not show.

Simply having what you have there doesn't help the game engine, it's searching for something that it doesn't know where it is.

 

even a custom patch needs to be treated like an addon.

 

for example

 

class CfgUnitInsignia
{
    class 2REP_FRANCE_color
    {
        displayName = "[2REP] France (Color)";
        texture = "2REP_Patches\data\patch\France_color.paa";
        author = "Road Runner";
    };

 

 

Notice the path to my custom patch?
The addon is called 2REP_Patches

 

The game engine now knows where to "find" the custom patch.

 

Share this post


Link to post
Share on other sites

road Runner,  I'm aware of config.cpp for addon. And the difference between config.cpp and description.ext for textures of resource paths.

 

There should be no need to have one more mod for displaying a custom insignia ! (Theoretically). Because it's just like sounds in cfgSounds or cfgMusic.. working fine from description.ext. Hopefully!

Your work around cfgUnitInsignia remains interesting for a mod.

 

As I said, the problem is not here. BIS_fnc_setUnitInsignia calls setObjectTextureGlobal which is broken in MP.

 

Sometimes, reading BI documentation makes you spill many times:

https://community.bistudio.com/wiki/Arma_3_Unit_Insignia

You can add a new insignia in Config.cpp and Description.ext.

 

That's wrong as far as you're trying to define the insignia in description.ext for a MP mission. (hosted) server and clients refer to the same class but not the same texture path.

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

×