Jump to content
Sign in to follow this  
DarkBall123

Problem with adding an item to inventory

Recommended Posts

Hello, I need to randomly select any unit from the EAST side and give this unit a bomb (object).

 

There is a code (running from initServer)

_units = allUnits select {side _x == EAST};

_unit = selectRandom _units;
_unit addItem "UMI_Weed_Bale";
_unit setVariable['bombUnit', true, true];

But here is the problem, as I did not try, the bomb is always added to the player-server (no matter what side he is). We tested the mission on the host server. I will be grateful for any hint.

Share this post


Link to post
Share on other sites

Where exactly are you running it from?

Do you mean initServer.sqf?

Is there a similar snippet running from a trigger or similar that might cause this?

Also try running this spawned with a time conditional to make sure it only runs with the mission already running:

_addBomb= [] spawn {
	waitUntil {time>1};
	waitUntil {count allUnits>=1};
	_units = allUnits select {side _x == EAST};
	_unit = selectRandom _units;
	_unit addItem "UMI_Weed_Bale";
	_unit setVariable['bombUnit', true, true];
};

Might not make a difference though, all I can think of without further detail, heh.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
26 minutes ago, Grumpy Old Man said:

Where exactly are you running it from?

Do you mean initServer.sqf?

Is there a similar snippet running from a trigger or similar that might cause this?

Also try running this spawned with a time conditional to make sure it only runs with the mission already running:


_addBomb= [] spawn {
	waitUntil {time>1};
	waitUntil {count allUnits>=1};
	_units = allUnits select {side _x == EAST};
	_unit = selectRandom _units;
	_unit addItem "UMI_Weed_Bale";
	_unit setVariable['bombUnit', true, true];
};

Might not make a difference though, all I can think of without further detail, heh.

 

Cheers

Thanks, I'll check it out

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  

×