Jump to content
Ulfgaar

Unit insignias on dedicated server

Recommended Posts

Greetings everyone!

I've searched wide and far for a solution to a problem im having with my groups squad patches only occationally showing on our dedicated server games. 
I've searched the forum for similar topics, and found only an old one which didnt make too much sense to me - nor did it work as i hoped (tho, might just be me doing it wrong). However, its an old thread - and people seem to ignore it for that reason.

We have two dedicated servers - one which is where our narrative campaigns are hosted. These campaigns are either a series of 4-5 missions connected to a campaign, or a persistent campaign with 4-5 phases. The other server is our training server, where people can log on and practice all sorts of things, from infantry tactics to vehicle and mod training/practice. We have our own modset, sporting squad insignias. We also operate with preset loadouts for each role - and would as such like to have the individual squad insignia show for each squad in multiplayer on a dedicated server, no matter if you've selected a loadout or not - and i want this to be JIP friendly, so that players connecting late can see the squad insignias of those already playing.

We also want the players to have their radio frequencies (TFAR) be set when they select a loadout, to ensure a minimum of radio problems during out games (simplicity - as the TFAR module acts a bit spotty at times).

This is what im operating with - the code is just for my testing mission, but the same code will be customized for the larger group, adding variable names for each role in the squad, once its made to work properly. Im am by no means a coder/scripter - so there are things i cannot do or understand yet.


initPlayerLocal.sqf

(This makes the players spawn in with their correct insignia showing on the dedicated server, before chosing a loadout).

{
if (str(player)in ['Wolf1']) then {
	[player,'SPAR_WOL1'] call BIS_fnc_setUnitInsignia;
	};	
if (str(player)in ['Bear1']) then {
	[player,'SPAR_BEA2'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Lion1']) then {
	[player,'SPAR_LIO3'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Rhino1']) then {
	[player,'SPAR_RHI1'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Scorpion1']) then {
	[player,'SPAR_SCO'] call BIS_fnc_setUnitInsignia;
	};
} remoteExec ["bis_fnc_call", 0, True];


onPlayerRespawn.sqf:

(This makes the players respawn in with their correct insignia showing on the dedicated server, up until chosing a new loadout - proved insignia had to be removed first, then reapplied before showing after respawn).

{
if (str(player)in ['Wolf1']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'SPAR_WOL1'] call BIS_fnc_setUnitInsignia;
	};	
if (str(player)in ['Bear1']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'SPAR_BEA2'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Lion1']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'SPAR_LIO3'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Rhino1']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'SPAR_RHI1'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['Scorpion1']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'SPAR_SCO'] call BIS_fnc_setUnitInsignia;
	};
} remoteExec ["bis_fnc_call", 0, True];

TFAR_Freq.sqf
(This us the script that will set the players radio to preset frequencies).

[(call TFAR_fnc_activeSwRadio), 1, "130.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 2, "131.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 3, "132.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 4, "133.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 5, "134.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 6, "135.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 7, "136.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeSwRadio), 8, "137.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 1, "40.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 2, "41.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 3, "42.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 4, "43.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 5, "44.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 6, "45.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 7, "46.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 8, "47.1"] call TFAR_fnc_SetChannelFrequency; 
[(call TFAR_fnc_activeLrRadio), 9, "48.1"] call TFAR_fnc_SetChannelFrequency;


SQL_2IC_Loadout.sqf
(Example of preset loadout - used by infantry squad leader and their 2IC)


comment "Exported from Arsenal by Ulfgaar";

comment "[!] UNIT MUST BE LOCAL [!]";
if (!local _this) exitWith {};

comment "Remove existing items";
removeAllWeapons _this;
removeAllItems _this;
removeAllAssignedItems _this;
removeUniform _this;
removeVest _this;
removeBackpack _this;
removeHeadgear _this;
removeGoggles _this;

comment "Add weapons";
_this addWeapon "rhs_weap_m16a4_imod_M203";
_this addPrimaryWeaponItem "rhsusf_acc_anpeq15side_bk";
_this addPrimaryWeaponItem "rhsusf_acc_eotech_552";
_this addPrimaryWeaponItem "rhs_mag_30Rnd_556x45_M855A1_Stanag";
_this addPrimaryWeaponItem "rhs_mag_M585_white";
_this addWeapon "MCC_TentDome";
_this addWeapon "rhsusf_weap_glock17g4";
_this addHandgunItem "rhsusf_mag_17Rnd_9x19_JHP";

comment "Add containers";
_this forceAddUniform "gear_OCP_kit02";
_this addVest "gear_platecarrier_OCP_02";
_this addBackpack "SPAR_tf_rt1523g_OCP";

comment "Add binoculars";
_this addWeapon "ACE_Vector";

comment "Add items to containers";
for "_i" from 1 to 5 do {_this addItemToUniform "ACE_fieldDressing";};
_this addItemToUniform "ACE_epinephrine";
for "_i" from 1 to 2 do {_this addItemToUniform "ACE_morphine";};
_this addItemToUniform "ACE_Flashlight_MX991";
_this addItemToUniform "ACE_IR_Strobe_Item";
_this addItemToUniform "ACE_EarPlugs";
for "_i" from 1 to 3 do {_this addItemToUniform "ACE_CableTie";};
_this addItemToUniform "ACE_microDAGR";
_this addItemToUniform "SPAR_Beret_Green";
_this addItemToUniform "ACE_MapTools";
_this addItemToUniform "G_Cigarette_F";
_this addItemToVest "ACE_tourniquet";
_this addItemToVest "rhsusf_acc_M952V";
_this addItemToVest "ACE_NVG_Gen4";
_this addItemToVest "ALIVE_Tablet";
for "_i" from 1 to 2 do {_this addItemToVest "HandGrenade";};
for "_i" from 1 to 2 do {_this addItemToVest "ACE_M84";};
_this addItemToVest "rhsusf_mag_17Rnd_9x19_JHP";
for "_i" from 1 to 6 do {_this addItemToVest "rhs_mag_30Rnd_556x45_M855A1_Stanag";};
_this addItemToVest "ACE_Chemlight_HiGreen";
_this addItemToVest "ACE_Chemlight_HiRed";
for "_i" from 1 to 2 do {_this addItemToVest "SmokeShell";};
_this addItemToVest "SmokeShellGreen";
_this addItemToVest "SmokeShellOrange";
for "_i" from 1 to 2 do {_this addItemToBackpack "1Rnd_SmokeRed_Grenade_shell";};
for "_i" from 1 to 2 do {_this addItemToBackpack "1Rnd_SmokeGreen_Grenade_shell";};
for "_i" from 1 to 5 do {_this addItemToBackpack "1Rnd_HE_Grenade_shell";};
_this addItemToBackpack "rhs_mag_M585_white";
_this addHeadgear "gear_ECH_OCP_14";
_this addGoggles "VSM_Shemagh_OD";

comment "Add items";
_this linkItem "ItemMap";
_this linkItem "ItemCompass";
_this linkItem "ItemWatch";
_this linkItem "tf_anprc152_1";

_handle = execVM "OnPlayerRespawn.sqf";
_handle = player execVM "TFAR_Freq.sqf"; 
waitUntil { isNull _handle };


The problem was initially that players lost their insignia when changing loadouts. This is why i've added this to the end of each preset loadout script:

_handle = execVM "OnPlayerRespawn.sqf";
_handle = player execVM "TFAR_Freq.sqf"; 
waitUntil { isNull _handle };

This sorted the TFAR radio frequencies, and works well (to what i can see at least).

The insignias however is a mystery - as the player changing the loadouts, can see his own, and others. But others can no longer see his. Example below:

Going to operate with 3 Players to explain this. Player A, Player B and Player C - on dedidcated server.

  • All 3 Players (A,B and C) spawn in - all can see their own and the others insignias.
  • Player A goes to get a preset loadout. He can still see his own, and the others insignias - however Player B and C can no longer see Player A insignia.
  • Player B then goes to get a presetloadout. Player B can see his own, and Player A and C insignias. Player C can also now see Player A insignia. However, Player A and C can no longer see player B insignia.
  • Player C goes to get preset loadout - and same pattern repeats. C can now see his own, and both A and B's. A can now also see B's. A and B can however no longer see C's.

 

So, this is my case and situation - and i feel im "close", but my lack of the actual coding language and scripting is holding me back - so i am now humbly coming before you guys in the great Arma 3 forum oracle, seeking help. 

Any help and pointers will be greatly appreciated - as i've been hitting my had through the wall with this issue for a long time now trying to figure it out. 

Best regards,
- Ulfgaar

Share this post


Link to post
Share on other sites

Too much to get into?

Basically, im after a way to have shoulder insignias visible for players on a dedicated server, which is JIP friendly and "reliable" (or as reliable as you get them in Arma). 

Im not talking about the "Units" group badge, but custom squad patches.

Share this post


Link to post
Share on other sites

Using player in MP environments can be problematic. Best to do something like 

//top of initPlayerLocal.sqf and onPlayerRespawn.sqf

_unit = this select 0;

//replace all instances of "player" with "_unit

though I think smarter folks might have suggested that "player" is fine in these particular instances. I prefer to err on the side of safety.

Another thing I noticed from the BIS_fnc_setUnitInsignia Biki entry:
 

Quote

Description:  Sets unit insignia (e.g., shoulder insignia on soldiers). See Arma 3 Unit Insignia for more details. This function is global and should work from any client. Do not remote execute

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks man, thats a good start - will do the changes and have a look. 

Luckily im not remote executing the SetUnitInsignia on the live server - but testing it on the test file. 

Share this post


Link to post
Share on other sites

Sort of off-topic, but you might also want to go through your loadout scripts and replace "comment" with "//" - see the Biki entry for comment.

 

This is easily done in one go with the "replace" function in Notepad++.

  • Like 1

Share this post


Link to post
Share on other sites

Despite the warnings from the Biki, the only way I've found to get insignias to show consistently is by remoteExec. You can call the function directly, no need to bis_fnc_call it. 

 

Example:

[player, "SPAR_LIO3"] remoteExec  ["BIS_fnc_setUnitInsignia", 0];

 

Instead of modifying onPlayerRespawn and initLocalPlayer, have you considered writing a single function which loads after the loadout scripts are done? It seems to be the more effective solution. 

i.e., assignInsignia.sqf
 

/*
	assignInsignia.sqf

	configures unit insignia

	Argument
	 1, unit <OBJECT>

	Return
	 unit

*/

// init
private _unit = param [0, player];

// switch-case
private _insignia = _unit call {

	if (str(_this) in ['Wolf1']) exitWith {"SPAR_WOL1"};
	if (str(_this) in ['Bear1']) exitWith {"SPAR_BEA2"};
	if (str(_this) in ['Lion1']) exitWith {"SPAR_LIO3"};
	// etc 
	// also -- this string check could definitely be optimised
};


// add insignia
[_unit, _insignia] remoteExec ["bis_fnc_setUnitInsignia", 0];

// end
_unit

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

As said, i'm no scripter - so what i have is what i've adapted and put together like frankenstein from a myriad of threads and pages where this or similar things have been discussed. 

So with that in mind, when you @nkenny say that the "this string check could definitely be optimised"...im not sure how to.

I'll do some testing with what you've provided me with here. 

And again, thanks folks - really appreciate the help!

 

Share this post


Link to post
Share on other sites

Everyone has to start somewhere.  😉 

By optimised, I mean just that.  However, I'm not sure the logic/significance by which insignia is assigned to units. Hence I could offer no improvement to it

 

-k 

  • Like 1

Share this post


Link to post
Share on other sites
19 hours ago, nkenny said:

Despite the warnings from the Biki, the only way I've found to get insignias to show consistently is by remoteExec. You can call the function directly, no need to bis_fnc_call it. 

 

Example:

[player, "SPAR_LIO3"] remoteExec  ["BIS_fnc_setUnitInsignia", 0];

 

Instead of modifying onPlayerRespawn and initLocalPlayer, have you considered writing a single function which loads after the loadout scripts are done? It seems to be the more effective solution. 

i.e., assignInsignia.sqf
 


/*
	assignInsignia.sqf

	configures unit insignia

	Argument
	 1, unit <OBJECT>

	Return
	 unit

*/

// init
private _unit = param [0, player];

// switch-case
private _insignia = _unit call {

	if (str(_this) in ['Wolf1']) exitWith {"SPAR_WOL1"};
	if (str(_this) in ['Bear1']) exitWith {"SPAR_BEA2"};
	if (str(_this) in ['Lion1']) exitWith {"SPAR_LIO3"};
	// etc 
	// also -- this string check could definitely be optimised
};


// add insignia
[_unit, _insignia] remoteExec ["bis_fnc_setUnitInsignia", 0];

// end
_unit

 


I've tested your script @nkenny and it works for the InitLocalPlayer.sqf 

_handle = execVM "AssignInsignia.sqf";

- where players spawn in their default "base" uniform with patches and everyone can see their own and each others patches. 

However - when not using onPlayerRespawn.sqf players spawn in with no insignia. When i try to use it, and refer to your script in the same way with:

_handle = execVM "AssignInsignia.sqf";

players still spawn in without their insignia (not visible to themselves, or others).

However, when i do this to your script, adding the [_this,''] call BIS_fnc_setUnitInsignia; to remove the insignia before reapplying them:

/*
	assignInsignia.sqf

	configures unit insignia

	Argument
	 1, unit <OBJECT>

	Return
	 unit

*/

// init
private _unit = param [0, player];

// switch-case
private _insignia = _unit call {
	[_this,''] call BIS_fnc_setUnitInsignia;
	if (str(_this) in ['Wolf1']) exitWith {"SPAR_WOL1"};
	if (str(_this) in ['Bear1']) exitWith {"SPAR_BEA2"};
	if (str(_this) in ['Lion1']) exitWith {"SPAR_LIO3"};
	if (str(_this) in ['Rhino1']) exitWith {"SPAR_RHI1"};
	if (str(_this) in ['Scorpion1']) exitWith {"SPAR_SCO"};
};


// add insignia
[_unit, _insignia] remoteExec ["bis_fnc_setUnitInsignia", 0];

// end
_unit

people respawn and can see their own insignia, but others cannot.

When i add:

_handle = execVM "AssignInsignia.sqf";

to the end of the loadout scripts, the same happens. You equip new gear - and you can see your own insignia, but other players cannot.

So basically - same problem persists. And i've also have no idea on how these insignias will show for JIP players.


The reason why i have it for both InitLocalPlayer.sqf  and onPlayerRespawn.sqf - as well as when changing loadouts - is because in our games, we start the game with "base uniforms", i.e - a uniform with just the Unit branch beret. I still want players to show off what squad they are part of for the briefing etc. Once they start their missions, they will select their loadouts according to what role they have selected, and when that happens - i still want them to show their Squad identity. Then lastly, when they are killed in battle and spawn in with the gear they had when they died, and then try get back into the battle - i still want them to show the squad insignia. 

So i need 4 things to happen:

- When players spawn into the server, they need to have their squad ID insignia applied.
- When Players change loadouts, their squad ID insignia needs to be applied/reapplied.
- When they respawn after death, their squad ID insignia needs to be applied/reapplied.
- All players joining the game, should see the insignias present on the players already in the game, and vice versa.

The list above is whats doing my head in tbh xD.

So that throughout their game - they will always show and carry their squad ID insignia - from the role they selected from the lobby (aka, selecting a role within said squads).

Share this post


Link to post
Share on other sites

Hmm. 

Keep in mind that when you are 'reseting' insignia, you are doing so only locally. The correct reset would happen just before you assign it: Also via  a remoteExec: 

 

// reset insignia
[_unit, ""] remoteExec ["bis_fnc_setUnitInsignia", 0];

// add insignia
[_unit, _insignia] remoteExec ["bis_fnc_setUnitInsignia", 0, true];

NB third argument for add insignia.  The true should make the update persistent for JIP. Not sure how well it plays with players whom have died multiple times however. 

 

The most sensible place to the assign insignia function would be only at the end of whatever gear scripts you are using. Surely newly joined or newly dead players also go through a gearscript of some sort? Or is it written directly into  InitLocalPlayer.sqf and onPlayerRespawn.sqf.  For performance reasons you would do well to create a functions library of some sort, then compile all of these commonly used functions into memory.  🙂

-k 

 

Share this post


Link to post
Share on other sites

We start off in our base, where people kit up for the mission. During mission when people die, they respawn in with the gear they had when they died - and they have a range of options for respawns, in anything from respawn tents of their squads - a forward medical vehicle, or back at HQ (whereupon they will need to be transported back to the front). 

So no, they dont reload their loudouts after each death - they for the most part continue the fight with what they had when they died up until ressupply points have been arranged. Also, gear is loaded using addAction options on gearcrates, which executes different loadout.sqf scripts. We do this to ensure that players only have what they are permitted depending on their role, with some extra boxes containing "limited" other gear which they can change out.

Quick question too:

Whats the difference between:

private _unit = param [0, player];

vs

_unit = this select 0;

?

Will check new codes.

Share this post


Link to post
Share on other sites
23 hours ago, Ulfgaar said:

Whats the difference between:

The first has a default value, and is properly privated.

The second does neither.

Both are not the way you are supposed to retrieve arguments though.

 

params ["_unit"];

 

Share this post


Link to post
Share on other sites

Someone know how to save insignia after die, and when the player respawn have the same insignia that he had when he died?

(Like script of saving loadout when player is die and spawn with the same loadout.)

Share this post


Link to post
Share on other sites

InitPlayerLocal.sqf

(Example of 4xSquads of 8 people - applies insignias at start)

if (!isDedicated) then {
if (str(player)in ['SQA1','SQA2','SQA3','SQA4','SQA5','SQA6','SQA7','SQA8']) then {
	[player,'YourLogoNameA'] call BIS_fnc_setUnitInsignia;
	};	
if (str(player)in ['SQB1','SQB2','SQB3','SQB4','SQB5','SQB6','SQB7','SQB8']) then {
	[player,'YourLogoNameB'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['SQC1','SQC2','SQC3','SQC4','SQC5','SQC6','SQC7','SQC8']) then {
	[player,'YourLogoNameC'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['SQD1','SQD2','SQD3','SQD4','SQD5','SQD6','SQD7','SQD8']) then {
	[player,'YourLogoNameD'] call BIS_fnc_setUnitInsignia;
	};
};


OnPlayerRespawn.sqf
(Removes insignia, before reapplying them again when players respawn)

if (!isDedicated) then {
if (str(player)in ['SQA1','SQA2','SQA3','SQA4','SQA5','SQA6','SQA7','SQA8']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'YourLogoNameA'] call BIS_fnc_setUnitInsignia;
	};	
if (str(player)in ['SQB1','SQB2','SQB3','SQB4','SQB5','SQB6','SQB7','SQB8']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'YourLogoNameB'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['SQC1','SQC2','SQC3','SQC4','SQC5','SQC6','SQC7','SQC8']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'YourLogoNameC'] call BIS_fnc_setUnitInsignia;
	};
if (str(player)in ['SQD1','SQD2','SQD3','SQD4','SQD5','SQD6','SQD7','SQD8']) then {
	[player,''] call BIS_fnc_setUnitInsignia;
	[player,'YourLogoNameD'] call BIS_fnc_setUnitInsignia;
	};
};



With Preset Loadouts, loaded up through AddActions and the use of .sqf scripts containing the loadout preset:
You'll need to add a line of code to each .sqf containing your loadout, and you'll need to add another .sqf as well.

At the end of each loadout.sqf add this

execVM "loadout_post.sqf";


This is the new .sqf you'll need to make (name it whatever you want, this is just what we use).
loadout_post.sqf

Sleep 1;

SetInsignia = 1;


You'll also need a repeatable trigger with this:

Repeatable Trigger

Condition:
SetInsignia == 1;

On Activation:
if (!isDedicated) then {_handle = player execVM "onPlayerRespawn.sqf"; SetInsignia = 0;};


This is just an example of what we're using and its working on a dedicated server and will apply insignias when they connect, when they respawn and when they pick a kit from our preset loadout boxes - this way our squad insignias and rank insignias are displayed throughout the game we're having.

 

Share this post


Link to post
Share on other sites

InitPlayerLocal.sqf    (Example of 4xSquads of 8 people - applies insignias at start)

 

This seems to have stopped working for Dedicated servers since that last A3 update in 2021. Does anyone know of a fix????

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

×