Jump to content
Sign in to follow this  
laxemann

Need urgent help with a random weapons crate script

Recommended Posts

Hey folks,

I wrote a small script in order to save a lot of time and work, basically what I want to do is to fill a crate with a random amount of weapons and mags which are getting selected from an array.

Works like a charm in SP, but not in MP.

I thought the g'lobal' commands would sync everything but apparently the variables still aren't the same for everyone, resulting in each player getting a different crate content.

So, here's the script for a pistol crate:

RC_Pist1.sqf

//Pistols
//nul = [this] execVM "Crates\RC_Pist1.sqf"
_crate = _this select 0;
ClearWeaponCargo _crate;
ClearMagazineCargo _crate;
[color="#00FF00"]///////////////////////////////////////////////////////////////////////Definition of variables///////////////////////////////////////////////////////////////////////
//Flashlight
_lamp = ["ACE_MugLite"];

//	    
_Weap1 = ["M9","glock17_EP1","Makarov","revolver_EP1","CZ_75_SP_01_PHANTOM","Colt1911","ACE_USP","ACE_Flaregun","ACE_TT","ACE_P226","Sa61_EP1"];


//		
_Mags1 = ["15Rnd_9x19_M9","17Rnd_9x19_glock17","8Rnd_9x18_Makarov","6Rnd_45ACP","18Rnd_9x19_Phantom","7Rnd_45ACP_1911","ACE_12Rnd_45ACP_USP","ACE_8Rnd_762x25_B_Tokarev","ACE_15Rnd_9x19_P226","20Rnd_B_765x17_Ball"];

//		
_SanZeug = ["Ace_Bandage","Ace_Bandage","Ace_Bandage","Ace_Bandage","Ace_Bandage","Ace_LargeBandage","Ace_LargeBandage","ACE_Morphine","ACE_Epinephrine"];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////[/color]


//Flashlight
_crate addWeaponCargoGlobal [_lamp select 0, random 1];	

//Weapons
_W1 = _Weap1 select random 10;
_W2 = _Weap1 select random 10;

_crate addWeaponCargoGlobal [_W1 , 1 + random 2];
_crate addWeaponCargoGlobal [_W2 , 1 + random 1];

//Random Mags
_crate addMagazineCargoGlobal [_Mags1 select random 9, random 3];
_crate addMagazineCargoGlobal [_Mags1 select random 9, random 3];
_crate addMagazineCargoGlobal [_Mags1 select random 9, random 3];
_crate addMagazineCargoGlobal [_Mags1 select random 9, random 3];

//Medic Stuff
_crate addMagazineCargoGlobal [_SanZeug select random 8, random 3];
_crate addMagazineCargoGlobal [_SanZeug select random 8, random 2];

////Fitting Magazines
//[color="#00FF00"]M9[/color]
if ((_W1 == "M9") OR (_W2 == "M9")) then
{
_crate addMagazineCargoGlobal ["15Rnd_9x19_M9", 2 + random 8];
};

//[color="#00FF00"]Glock[/color]
if ((_W1 == "glock17_EP1") OR (_W2 == "glock17_EP1")) then
{
_crate addMagazineCargoGlobal ["17Rnd_9x19_glock17", 2 +random 9];
};

//[color="#00FF00"]Makarov[/color]
if ((_W1 == "Makarov") OR (_W2 == "Makarov")) then
{
_crate addMagazineCargoGlobal ["8Rnd_9x18_Makarov", 4 + random 10];
};

//[color="#00FF00"]Revolver[/color]
if ((_W1 == "revolver_EP1") OR (_W2 == "revolver_EP1")) then
{
_crate addMagazineCargoGlobal ["6Rnd_45ACP", 2 + random 12];
};


//[color="#00FF00"]Sa61_EP1[/color]
if ((_W1 == "Sa61_EP1") OR (_W2 == "Sa61_EP1")) then
{
_crate addMagazineCargoGlobal ["20Rnd_B_765x17_Ball", 2 + random 12];
};


//[color="#00FF00"]Phantom[/color]
if ((_W1 == "CZ_75_SP_01_PHANTOM") OR (_W2 == "CZ_75_SP_01_PHANTOM")) then
{
_crate addMagazineCargoGlobal ["18Rnd_9x19_Phantom", 1 + random 8];
};

//Colt1911
if ((_W1 == "Colt1911") OR (_W2 == "Colt1911")) then
{
_crate addMagazineCargoGlobal ["7Rnd_45ACP_1911", 1 + random 10];
};

//[color="#00FF00"]USP_Tac[/color]
if ((_W1 == "ACE_USP") OR (_W2 == "ACE_USP")) then
{
_crate addMagazineCargoGlobal ["ACE_12Rnd_45ACP_USP", 1 + random 10];
};

//Flaregun
if ((_W1 == "ACE_Flaregun") OR (_W2 == "ACE_Flaregun")) then
{
_crate addmagazinecargoglobal ["ACE_SSGreen_FG", 5 + random 10];
_crate addmagazinecargoglobal ["ACE_SSRed_FG", 5 + random 10];
_crate addmagazinecargoglobal ["ACE_SSWhite_FG", 5 + random 10];
_crate addmagazinecargoglobal ["ACE_SSYellow_FG", 5 + random 10];
};


//TT
if ((_W1 == "ACE_TT") OR (_W2 == "ACE_TT")) then
{
_crate addMagazineCargoGlobal ["ACE_8Rnd_762x25_B_Tokarev", 1 + random 10];
};

//P226
if ((_W1 == "ACE_P226") OR (_W2 == "ACE_P226")) then
{
_crate addMagazineCargoGlobal ["ACE_15Rnd_9x19_P226", 1 + random 10];
};

//[color="#00FF00"]Sa61[/color]
if ((_W1 == "ACE_P226") OR (_W2 == "ACE_P226")) then
{
_crate addMagazineCargoGlobal ["20Rnd_B_765x17_Ball", 2 + random 8];
};

I've found this thread already, but it's not quite what I'm looking for since the amounts have tobe different each time.

Thanks in advance,

Laxe

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  

×