Jump to content
Sign in to follow this  
Ophelian

Custom ammo box in MP

Recommended Posts

Hi,

I googled the heck out of this and just can't figure it out. Everywhere i look its Arma 2 related and i'm not sure to what extent the two are similar.

So basically i have 6 ammo boxes (B_supplycrate_F) and add this init code to them (ammo type is trivial in that case):

this allowDamage false;

clearWeaponCargo this;

clearMagazineCargo this;

clearItemCargo this;

this addMagazineCargoGlobal["RH_30Rnd_556x45_Mk262",250];

this addMagazineCargoGlobal["1Rnd_HE_Grenade_shell",100];

this addMagazineCargoGlobal["AT4_HEAT",7];

this addMagazineCargoGlobal["AT4_HP",7];

this addMagazineCargoGlobal["100Rnd_762_MAG_Belt",30];

this addMagazineCargoGlobal["100_Rnd_762_Mag_Belt_TR",30];

this addMagazineCargoGlobal["100_Rnd_762_Mag_Belt_TR5",30];

this addMagazineCargoGlobal["hlc_100Rnd_762x51_B_M60E4",30];

this addMagazineCargoGlobal["hlc_100Rnd_762x51_T_M60E4",30];

this addMagazineCargoGlobal["hlc_100Rnd_762x51_M_M60E4",30];

this addMagazineCargoGlobal["200Rnd_556_F89_Belt",30];

this addMagazineCargoGlobal["200Rnd_556_F89_Belt_TR",30];

this addMagazineCargoGlobal["200Rnd_556_F89_Belt_TR5",30];

I made one template and copied the others.

The problem is this: when i preview the mission in the editor everything works, all the ammo boxes clean themselves and put the right amount of ammunition to the box. But when i upload it to the dedicated server, not only the "clearXXX" commands don't work, but the ammobox has multiplied the ammo (for example, all the LMG ammo spawns 240 mags instead of 30). Is there a difference between "addMagazineCargoGlobal" and "addMagazineCargo" or do i have to add "Global" to the 3 "clearXXX" commands? I'm at a loss here.

Am i using the right init commands or these are old ones? I'm missing something and i know its something trivial.

Thanks for taking a look at this.

Share this post


Link to post
Share on other sites

Change the Clear commands to their Global counterpart and wrap the whole thing in a isServer check so only the server is controlling the box's inventory rather than everyone connecting.

this allowDamage false;
if (isServer) then {
clearWeaponCargoGlobal this;
clearMagazineCargoGlobal this;
clearItemCargoGlobal this;
this addMagazineCargoGlobal["RH_30Rnd_556x45_Mk262",250];
this addMagazineCargoGlobal["1Rnd_HE_Grenade_shell",100];
this addMagazineCargoGlobal["AT4_HEAT",7];
this addMagazineCargoGlobal["AT4_HP",7];
this addMagazineCargoGlobal["100Rnd_762_MAG_Belt",30];
this addMagazineCargoGlobal["100_Rnd_762_Mag_Belt_TR",30];
this addMagazineCargoGlobal["100_Rnd_762_Mag_Belt_TR5",30];
this addMagazineCargoGlobal["hlc_100Rnd_762x51_B_M60E4",30];
this addMagazineCargoGlobal["hlc_100Rnd_762x51_T_M60E4",30];
this addMagazineCargoGlobal["hlc_100Rnd_762x51_M_M60E4",30];
this addMagazineCargoGlobal["200Rnd_556_F89_Belt",30];
this addMagazineCargoGlobal["200Rnd_556_F89_Belt_TR",30];
this addMagazineCargoGlobal["200Rnd_556_F89_Belt_TR5",30];
};

Share this post


Link to post
Share on other sites

Larrow's solution will work on dedicated server.

Edited by DavidZi
ninja'd

Share this post


Link to post
Share on other sites

THanks Larrow for the help. Tonight ill add the corrections to my mission. So if i understand, my old code was influenced by the JIP clients, so the new one because it is in a "if" condition with the "isServer" it specifies that it is the server only that will populate the box? I'm a total noob when it comes to this and i'm trying to understand to the best of my knowledge.

Thank you very much for the help!

Share this post


Link to post
Share on other sites

Starting new thread to raise my question about side-issue im having with a custom box in MP server. Mod please delete this sorry.

Edited by zyg0tic

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  

×