Jump to content
za0

Remove Item from Inventory

Recommended Posts

I'm using Ace mod and there is that plasma sack with the id as follow:
ACE_plasmaIV_250 

Well, I'm trying to remove it from my inventory when I reach the trigger area with the command :
this removeItem ACE_plasmaIV_250;

...but nothing happens
I've also tried use: this removeItemFromBackpack ACE_plasmaIV_250;   
with the item in my backpack but still nothing happens... :l
Any idea?

tks in advance!

Share this post


Link to post
Share on other sites

The command removeItem should do the job, even if it is in your uniform, vest or backpack.

From your example you aren't using the command right.

this removeItem "ACE_plasmaIV_250";

Note the string, or quotes, around the class name.


Now. How you use it in this instance depends on a few things.
Are you only playing Single Player? Or, Is it Multiplayer?

If it's Single Player, you can simply use the following in the On Activation field of your trigger;

player removeItem "ACE_plasmaIV_250";



 

Share this post


Link to post
Share on other sites

It worked! The problem was the quotes.
I'm creating for a multiplayer 🙂 Each character will have a different variable name so these scripts will also have their names to work correctly.

But I'm with another problem here... this script works but it only removes 1 item from the inventory... Is there a way to remove multiple items, like 5 plasma sacks at once?

Share this post


Link to post
Share on other sites
1 hour ago, za0 said:

this script works but it only removes 1 item from the inventory... Is there a way to remove multiple items, like 5 plasma sacks at once?


There is also removeItems which "Removes all items with given class name from the inventory".

//	Removes all "ACE_plasmaIV_250" from a unit.

this removeItems "ACE_plasmaIV_250";

 

But if the unit had 7 250mL Plasma IV Bags, for example, and you only wanted to remove 5 of them.

You would use:

//	Removes only 5 "ACE_plasmaIV_250" from the unit.

for "_i" from 1 to 5 do
{
	this removeItem "ACE_plasmaIV_250";
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Remove all this classname from the calling unit,

[this, "ACE_plasmaIV_250"] call {{(_this #0) removeItem _x} forEach (((uniformItems (_this #0) + vestItems (_this #0) + backpackItems (_this #0))) select {_x== (_this #1)})}

If you'll be calling this often,

you_remove_strings= {
	{(_this #0) removeItem _x} forEach (((uniformItems (_this #0) + vestItems (_this #0) + backpackItems (_this #0))) select {_x== (_this #1)})
};

//call
[this, "ACE_plasmaIV_250"] call you_remove_strings

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

tks guys, for everything

Share this post


Link to post
Share on other sites
On 8/30/2021 at 7:23 PM, Maff said:

The command removeItem should do the job, even if it is in your uniform, vest or backpack.

From your example you aren't using the command right.


this removeItem "ACE_plasmaIV_250";

Note the string, or quotes, around the class name.


Now. How you use it in this instance depends on a few things.
Are you only playing Single Player? Or, Is it Multiplayer?

If it's Single Player, you can simply use the following in the On Activation field of your trigger;


player removeItem "ACE_plasmaIV_250";



 

How should I be using removeItem in MP, dedicated?

Share this post


Link to post
Share on other sites
On 8/29/2022 at 3:47 AM, Soapbox0331 said:

How should I be using removeItem in MP, dedicated?


Better late than never...

I don't see why removeItem wouldn't work in MP.
I'm still wary of answering dedicated server related questions.

As time has gone by... Do you have the answer(s)?  

Share this post


Link to post
Share on other sites
36 minutes ago, Maff said:

As time has gone by... Do you have the answer(s)?

Thanks @Maff, I actually have a test set up...will let you know how it goes.

  • Like 1

Share this post


Link to post
Share on other sites

removeItem is GA/GE, so it should work just fine in MP/dedi.

  • Like 1
  • Thanks 1

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

×