Jump to content

Sign in to follow this  
kocrachon

Weapon script not running on other clients.

Recommended Posts

So I am running a script that arms all of my units at the start of the mission. Each unit has this in their init line.

nul = [this] execVM "SilencedMk17.sqf

And below is the entire script. It works for me locally and on any AI, but not to any of the players that connect to my local server I host on my desktop.

_soldier = _this select 0;

removeallweapons _soldier;
removeBackpack _soldier;
_soldier addbackpack "US_Patrol_Pack_Specops_EP1";
clearMagazineCargo (unitBackpack _soldier);

_soldier addweapon "NVGoggles";
_soldier addweapon "Binocular_Vector";

_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addweapon "SCAR_H_CQC_CCO_SD";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "20Rnd_762x51_SB_SCAR";
_soldier addmagazine "PipeBomb";
_soldier addmagazine "PipeBomb";

_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addweapon "M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";
_soldier addmagazine "15Rnd_9x19_M9SD";

(unitBackpack _soldier) addMagazineCargo ["20Rnd_762x51_SB_SCAR",4];
(unitBackpack _soldier) addMagazineCargo ["15Rnd_9x19_M9SD",4];	


Share this post


Link to post
Share on other sites

Not quite sure what the problem is. What do you mean by "not running"? Newly joined players get stock equipment instead of one that you have defined in your script? I think that you will need JIP support for your mission.

init.sqf (Put into mission directory):

if(isNull player) then { //If player joins after game was started
[] spawn { //New script thread
	waitUntil {player == player}; //Wait until player is initialized
	[player] execVM "SilencedMk17.sqf";
};
};

Not sure if this will work, but it should be something like this.

Share this post


Link to post
Share on other sites

Its not JIP. and yes, when the mission starts the other people still have stock gear. So My character is the only one with the custom load out.

Share this post


Link to post
Share on other sites

Why not just put this in the init of each player?

removeBackpack this;
removeAllItems this;
removeallWeapons this;
this addbackpack "US_Patrol_Pack_Specops_EP1";
clearMagazineCargo (unitBackpack this);
(unitBackpack this) addMagazineCargo ["20Rnd_762x51_SB_SCAR",4];
(unitBackpack this) addMagazineCargo ["15Rnd_9x19_M9SD",4];
{this addMagazine "20Rnd_762x51_SB_SCAR"} forEach [1,2,3,4,5,6,7,8];
{this addMagazine "15Rnd_9x19_M9SD"} forEach [1,2,3,4,5,6,7,8];
{this addMagazine "PipeBomb"} forEach [1,2];
this addWeapon "SCAR_H_CQC_CCO_SD";
this addWeapon "M9SD";
this addWeapon "NVGoggles";
this addweapon "Binocular_Vector";
this addWeapon "ItemWatch";
this addWeapon "ItemMap";
this addWeapon "ItemCompass";
this addWeapon "ItemGPS";
this addWeapon "ItemRadio";

Maybe use one of those large backpacks with 14 slots :)

ArmA_2_OA:_Backpacks

http://www.kylania.com/ex/?p=55

Share this post


Link to post
Share on other sites
  HavocDemon said:
Its not JIP. and yes, when the mission starts the other people still have stock gear. So My character is the only one with the custom load out.

It doesn't matter. You have to wait execution until player entity is not null, because all units under player command are local to the client machine. So two things when you want to operate with player or player unit's group: 1) Make sure the script referencing them do not run on any dedicated server, and 2) Wait until player is not null (that means the player is ready and therefore their local units). Something like this:

waitUntil {!isNull player};

Should do the trick.

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
Sign in to follow this  

×