Jump to content
Sign in to follow this  
eXpouk

Trouble Adding Items to Crates in MP

Recommended Posts

Hey guys,

Recently I've had some trouble when removing/adding weapons/items/magazines etc from crates using an init line. The games we play at the moment are MP and hosted on a players PC rather than a dedicated server.

When I use this additemcargo ["whatever item", 5] it only adds the item for the player hosting the server and not all the connected clients. I thought I could solve this by using additemcargoGlobal ["whatever item", 5]. Now this works but the problem I have is, is that it duplicates the items for every client connected to the game. So for example, if the crates init had additemcargoGlobal ["GPS", 5] and there were 5 players, it would put 25 GPS in the crate.

For balancing/realism reasons I was wondering if theres a way I can get this to work in multiplayer without it duplicating for every client?

Thanks

Share this post


Link to post
Share on other sites
if ( isServer ) then {
  this addItemCargoGlobal ["whatever", 5];
};

So only the server globally adds stuff to the crate.

Edited by Larrow

Share this post


Link to post
Share on other sites
if ( isServer ) then {
   addItemCargoGlobal ["whatever", 5];
};

So only the server globally adds stuff to the crate.

Would this have to be ran via .sqf?

Share this post


Link to post
Share on other sites

Either that or a trigger with condition

isServer

Share this post


Link to post
Share on other sites

Should be ok from the init, if you find stuff is missing you may need to wait until time > 0..... e.g for testing from a crates init box

h = this spawn {
if ( isServer ) then {
	waitUntil {time > 0};
	clearItemCargoGlobal _this;
	clearMagazineCargoGlobal _this;
	clearWeaponCargoGlobal _this;
	_this addItemCargoGlobal [uniform player, 5];
};
};

Will clear the crates contents and add five uniforms of the type the host is wearing to the crate (notice i said host and will not be dedicated friendly) for testing only.

Share this post


Link to post
Share on other sites

Will test it today.

Thanks for your help!

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  

×