Jump to content
blackyesp

Player's loadout issue / init.sqf

Recommended Posts

Hello,

I'm having some issues trying to set the same custom loadout to every playable unit on my MP mission. I'm trying to spawn every player with only 4 rounds inside the handgun's mag and I can't get it to work on MP. I've got different outcomes, but generally players spawn without a single bullet. I'm using the following Init.sqf:

removeAllWeapons player;
removeAllItems player;
removeAllAssignedItems player;
removeUniform player;
removeVest player;
removeBackpack player;
removeHeadgear player;
removeGoggles player;

player forceAddUniform "U_BG_Guerilla1_1";
for "_i" from 1 to 2 do {player addItemToUniform "FirstAidKit";};

player addVest "V_Rangemaster_belt";
player addItemToVest "SmokeShell";
player addBackpack "B_AssaultPack_Kerry";
player addHeadgear "H_Bandanna_camo";

player addWeapon "hgun_Pistol_heavy_02_F";
player addWeapon "Binocular";

player setAmmo [handgunWeapon player, 4];

player linkItem "ItemCompass";
player linkItem "ItemWatch";
player linkItem "ItemRadio";

There is no unit defined as "Player" just "Playable" ones, because the outcome for the "player" unit was always different, as I'm testing this on my dedicated server. The mission is meant to be played on server, but I also want it working on my dedicated server.

Any Idea what is happening? What am I obviusly missing?

 

Thank you in advance!

Share this post


Link to post
Share on other sites

Add a magazine, otherwise you're just giving them an empty weapon (unless they already have the mags on them).

Share this post


Link to post
Share on other sites

Why not use setUnitLoadout?

 

Loadout's are so easy...

player setUnitLoadout
[	[],
	[],
	["hgun_Pistol_heavy_02_F","","","",["6Rnd_45ACP_Cylinder",4],[],""],
	["U_BG_Guerilla1_1",[["FirstAidKit",2]]],
	["V_Rangemaster_belt",[["SmokeShell",1,1]]],
	["B_AssaultPack_Kerry",[]],
	"H_Bandanna_camo",
	"",
	["Binocular","","","",[],[],""],
	["","","ItemRadio","ItemCompass","ItemWatch",""]
];

More Information

  • Like 1

Share this post


Link to post
Share on other sites

Put your commands in initPlayerLocal.sqf not init.sqf

 

This will load gun with first mag and give player 3 spare mags.
Replace this

player addWeapon "hgun_Pistol_heavy_02_F";
player setAmmo [handgunWeapon player, 4];

with this

[player,'hgun_Pistol_heavy_02_F',4] call BIS_fnc_addWeapon;

Also link items with this.

{player linkItem _x} forEach ['ItemCompass','ItemWatch','ItemRadio'];
  • Like 1

Share this post


Link to post
Share on other sites

Hey!

Thank you very much for the reply guys!

 

I actually tried both Scripts.

 

@Lucullus Nice input! SetUnitLoadout looks very intuitive and easy to use. I will give it a chance in future missions. Your code also worked perfectly and solved all my needs :) Great help!

I'm afraid I ended using @Beerkan's alternative, because of the initPlayerLocal.sqf tipp. I wasn't aware of this file and I'm sure it will spare me a lot of init problems for MP from now on. Thank you for that! I also prefer using BIS_fnc while scripting, so I decided to give it a try. The lines you gave me did exactly what you said. So I just changed it to the following and it worked perfectly: 

[player,'hgun_Pistol_heavy_02_F',1] call BIS_fnc_addWeapon;
player setAmmo [handgunWeapon player, 4];

(also thank you for the forEach tipp!)

 

Both alternatives worked great! Thank you again guys!

 

Problem solved.

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

×