Jump to content
Robustcolor

Custom player loadout

Recommended Posts

Hi, for some reason this is not working 100% when i try to load a custom loadout for all players in my mission. For me as a host it works but not for joining players.

 

This is how i execute this.

InitPlayerLocal.sqf

[] spawn Robust_fnc_Loadout;

 My loadout function.

this = player;

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 containers";
this forceAddUniform "UNS_ARMY_BDU";
this addVest "UNS_M1956_A8";
this addBackpack "UNS_Alice_3";

comment "Add binoculars";
this addWeapon "uns_binocular_army";

comment "Add items to containers";
this addItemToVest "uns_kabar";
for "_i" from 1 to 5 do {this addItemToBackpack "FirstAidKit";};
for "_i" from 1 to 5 do {this addItemToBackpack "uns_m61gren";};
this addItemToBackpack "uns_m18red";
this addItemToBackpack "uns_m18white";
this addHeadgear "UNS_M1_3A";

comment "Add items";
this linkItem "ItemMap";
this linkItem "ItemCompass";
this linkItem "ItemWatch";
this linkItem "ItemRadio";

comment "Set identity";
[this,"WhiteHead_04_cfaces_lrrpcamo02",""] call BIS_fnc_setIdentity;

 

Share this post


Link to post
Share on other sites

this is a reserved variable! this = player; makes no sense, replace it with player. Also if you leave the last line all your players will have the same identity

Share this post


Link to post
Share on other sites
41 minutes ago, Mr H. said:

this is a reserved variable! this = player; makes no sense, replace it with player. Also if you leave the last line all your players will have the same identity

So just replace every this with player? I don't need this select 1 or _unit = player; ?

 

Same identity because of camo face.

Share this post


Link to post
Share on other sites
7 minutes ago, Robustcolor said:

So just replace every this with player? I don't need this select 1 or _unit = player; ?

yes,no

Share this post


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

this is a reserved variable!

Huh? No it isn't. Where did you get that from?
this in init fields is just a local variable.

In the script above the user just sets it as a global variable, that's perfectly fine (besides that all global variables should have a tag).

 

4 hours ago, Robustcolor said:

For me as a host it works but not for joining players.

That already tells you that the script is valid.

 

Question is why it doesn't work for others. Where is "Robust_fnc_Loadout" being defined? CfgFunctions?

Share this post


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

this is a reserved variable! this = player; makes no sense, replace it with player. Also if you leave the last line all your players will have the same identity

Depends on the context, in initPlayerLocal it is just a normal variable like any other

Share this post


Link to post
Share on other sites
27 minutes ago, Dedmen said:

Huh? No it isn't. Where did you get that from?
this in init fields is just a local variable.

In the script above the user just sets it as a global variable, that's perfectly fine (besides that all global variables should have a tag).

 

That already tells you that the script is valid.

 

Question is why it doesn't work for others. Where is "Robust_fnc_Loadout" being defined? CfgFunctions?

Yes, it's defined in CfgFunctions. I noticed that the other player never loaded my loadout function, Only me loaded it. So not sure what's going.

Share this post


Link to post
Share on other sites

Could it be a jip problem? Maybe i should execute the loadout from the playable unit init.

Share this post


Link to post
Share on other sites

From initPlayerLocal.sqf, you run the script locally. So, that can't work 100%, because you miss the global commands: addWeaponGlobal  & addBackpackGlobal.

[object, face, speaker, pitch, callsign] call BIS_fnc_setIdentity is effects_local.gifSo remoteExec it. but it's a special function.  FOLLOW BIKI for this command.

 

Now, if you don't need to change anything from start, but just customizing your units, edit loadouts in editor. That's simpler.

 

 

  • Like 1
  • Thanks 1

Share this post


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

From initPlayerLocal.sqf, you run the script locally. So, that can't work 100%, because you miss the global commands: addWeaponGlobal  & addBackpackGlobal.

[object, face, speaker, pitch, callsign] call BIS_fnc_setIdentity is effects_local.gifSo remoteExec it.

 

Now, if you don't need to change anything from start, but just customizing your units, edit loadouts in editor. That's simpler.

 

 

So i guess have 3 options then, one is to remoteExec everything, second is adding everything in the InitPlayerLocal.sqf and changing this to player and last just editing in the editor.

 

If i need to use setIdentity in InitPlayerLocal i guess it will be working if changing this to player right?

 

[this,"WhiteHead_04_cfaces_lrrpcamo02",""] call BIS_fnc_setIdentity; 

To

[Player,"WhiteHead_04_cfaces_lrrpcamo02",""] call BIS_fnc_setIdentity;

Share this post


Link to post
Share on other sites

Don't remoteExec everything. It's a waste of net resource.

You just have to use global commands for (old) commands I gave you. If I'm right, all the other ones have already global effect (EG), in initPlayerLocal.

 

 BIS_fnc_setIdentity is EL. That means, when you run it, you get the effect locally. BUT, this function is already "customized" to make it work in MP and JIP compatible (see BIKI). So you can write:

if (isServer) then {[this,"WhiteHead_04_cfaces_lrrpcamo02",""] call BIS_fnc_setIdentity};

in the init field of the playable unit.

  • Like 2

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

×