Jump to content

Recommended Posts

When we place any sort of code into a unit's init field does it apply to all clients for a hosted server?

 

The question came as a troubling from ... will the insignia appear to all clients if I place this in some units init:

 

[this,"enemy"] call BIS_fnc_setUnitInsignia;

 

and on a side-note there will be quite a few units using the above. Is there any other more fps friendly way to place the insignia to those specific units?

Share this post


Link to post
Share on other sites

So,

The init field of any edited object runs on server + clients when JIP (like init.sqf). The reason why it's usually preferable to add a server condition if (isServer) then {...} each time you have a global effect in your code and you don't want to "reset" it on each JIP (ex.: loadout for units)

 

Bis_fnc_setUnitInsignia uses 2 global commands: setObjectMaterialGlobal and setObjectTextureGlobal

That's a good reason to run it on server only.

if (isServer) then {[this,"enemy"] call BIS_fnc_setUnitInsignia};

 

Other remark from BIKI:

If setObjectTextureGlobal is executed from init of a vehicle, it may be too soon and fail to broadcast to other vehicle instances on network and become JIP compatible. The workaround is to delay setting the texture until after the vehicle is fully initialised

 

0 = this spawn {waitUntil {count allPlayers >0}; if (isServer) then {[_this,"enemy"] call BIS_fnc_setUnitInsignia} };

 

Now, "enemy" is not a common Vanilla Arma insignia. All PCs must know this mod (and find the insignia!). Good luck with that.

I suggest you test with a standard insignia before trying a custom one.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, JohnKalo said:

When we place any sort of code into a unit's init field does it apply to all clients for a hosted server?

It runs on all clients, present and JIP, so you don't want to execute setUnitInsignia from init field, because you will be interfering with already global nature of the function, the behaviour in which case will be undefined. Execute this function once.

  • Thanks 1

Share this post


Link to post
Share on other sites

@pierremgi

@killzone_kid

 

Thanks guys! So judging from the above in the init field of the units I place:

 

if (isServer) then {[this,"enemy"] call BIS_fnc_setUnitInsignia};

 

That way it will run once even if it is in the init field of the units.
 

Quote


Now, "enemy" is not a common Vanilla Arma insignia. All PCs must know this mod (and find the insignia!). Good luck with that.

I suggest you test with a standard insignia before trying a custom one.

 

 

It is an image located in the mission folder. Enemy is just the name given in the description.txt.

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

×