Jump to content
Sign in to follow this  
combat-agent

Random weapons crate on MP

Recommended Posts

So I put together a script that picks random weapons and ammo and puts them in a crate. It work great, except on multiplayer. As I researched the problem, I figured out that the contents of the crate are, unfortunately, not global.

So first of heres the script:

init.sqs

xplane=0;
handguns = ["M9","Colt1911","glock17_EP1","revolver_EP1","UZI_EP1"];
publicVariable "handguns";
mags = ["15Rnd_9x19_M9","7Rnd_45ACP_1911","17Rnd_9x19_glock17","6Rnd_45ACP","30Rnd_9x19_UZI"]
publicVariable "mags";

crate.sqs

_dude = _this select 0;
clearweaponcargo _dude;
clearmagazinecargo _dude;

rndx1 = floor random (count handguns);
publicVariable "xplane";

_handgun = handguns select xplane;
_dude addweaponcargo [_handgun,1];
_mag = mags select xplane;
xplane = floor (random 4);
publicVariable "xplane";
_dude addmagazinecargo [_mag,xplane];

The script is executed from the crates init line. The problem is, everyone has different weapons spawned. I made all the random numbers global variables, but that still didnt help. So the stuff spawns, but people cant grab any weapon or item that didnt spawn in from the servers selected weapons.

So is there a way around this? Is there a way to make it so every machines crate gets the same random items?

Thanks.

Share this post


Link to post
Share on other sites

addWeaponCargoGlobal with client exit after clearing cargo.

You don't need semicolons in sqs btw.

Share this post


Link to post
Share on other sites

That did the trick, I cant believe I didnt come across that though all the trouble I went trough. I use the semicolons as a standard practice as Im tryin to convert over to .sqfs. Love your zombie mission oh by the way.

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  

×