Jump to content
Sign in to follow this  
kocrachon

Weapon Script not function in MP

Recommended Posts

So instead of always having to manually change the load out in the editor, I make a bunch of weapon scripts that set the inventory to a bunch of pre-loaded loadouts that I prefer. They work fine in the SP enviorment with the player and the AI, but once I try to use them online, the other players dont get their gear, where as I (the host) do. Perhaps I am not writing it correctly for the online environment?

This is the init live I have for some of them...

_soldier = [this] execVM "SFMedic.sqf"; 

_soldier = [this] execVM "riflemanat.sqf"; 

and here is an example script.

_soldier = _this select 0;

removeallweapons _soldier;
clearMagazineCargo (unitBackpack _soldier);

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

_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addweapon "SCAR_L_STD_Mk4CQT";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "30Rnd_556x45_Stanag";
_soldier addmagazine "SmokeShell";
_soldier addmagazine "SmokeShell";

_soldier addmagazine "15Rnd_9x19_M9";
_soldier addweapon "M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";
_soldier addmagazine "15Rnd_9x19_M9";

(unitBackpack _soldier) addMagazineCargo ["30Rnd_556x45_Stanag",4];
(unitBackpack _soldier) addMagazineCargo ["15Rnd_9x19_M9",4];

Share this post


Link to post
Share on other sites

How exactly are you calling those scripts? You are putting them in the init of each unit?

you could have a script launched by a trigger set to condition local player and set to repeat. Then in on activation call a script that has a case switch and launches the appropriate script depending on class.

Share this post


Link to post
Share on other sites
How exactly are you calling those scripts? You are putting them in the init of each unit?

you could have a script launched by a trigger set to condition local player and set to repeat. Then in on activation call a script that has a case switch and launches the appropriate script depending on class.

Yes it is the init of each line.

I also want to make sure the weapons load on the AI characters as well for when a player isn't present...

Share this post


Link to post
Share on other sites

One possible option is to name all of your playable units and then use something like below (not adjusted for your loadouts but you should get the idea):

Units named

op1, op2, op3, op4, medic1, medic2

trigger

Condition: local player
On Act: _loadout = [] execVM "scripts\gear.sqf"

scripts\gear.sqf

// ====================================================================================
waituntil {!isnil "bis_fnc_init"};

private ["_loadout"];

sleep .1;

// ====================================================================================

// DEFINE UNIT TYPE LOADOUTS
// The following blocks of code define loadouts for each type of unit (the unit type is passed to the script in the first variable).

_loadout = switch (true) do {
   case (player in [op1, op2, op3, op4]) : {"op"};
   case (player in [medic1, medic2]) : {"medic"};
   };

// ====================================================================================

// LOADOUT: OPERATOR

switch (_loadout) do {
  case "op":
  {
     removeallweapons player;
     {player addmagazine "20Rnd_762x51_SB_SCAR";} count [1,2,3,4,5,6,7,8];
     player addmagazine "Pipebomb";
     {player addmagazine "HandGrenade_West";} count [1,2,3];
     {player addmagazine "7Rnd_45ACP_1911";} count [1,2,3,4,5,6,7,8];
     player addweapon "NVGoggles";
     player addweapon "SCAR_H_CQC_CCO_SD";
     player addweapon "Colt1911";
     player selectweapon "SCAR_H_CQC_CCO_SD";
  };

// ====================================================================================

// LOADOUT: MEDIC

  case "medic":
  {
     removeallweapons player;
     {player addmagazine "20Rnd_762x51_SB_SCAR";} count [1,2,3,4,5,6,7,8];
     player addmagazine "Pipebomb";
     {player addmagazine "HandGrenade_West";} count [1,2,3];
     {player addmagazine "7Rnd_45ACP_1911";} count [1,2,3,4,5,6,7,8];
     player addweapon "NVGoggles";
     player addweapon "SCAR_H_CQC_CCO_SD";
     player addweapon "Colt1911";
     player selectweapon "SCAR_H_CQC_CCO_SD";
  };

// ====================================================================================
};

EDIT: Just noticed your new reply, this won't help for AI

Edited by BearBison
added ref last post

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  

×