Question on wiki

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
Can OnItemAdded and OnItemRemoved track where the add/remove thing?
For example to check if BoxLoot(clone) was added to an M4 player
Is it possible to track the use of the subject?For example, eating a meal or dressing with a bandage
How can I obtain items that are in inventory for example?You need to drop things out of the box
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
You are really hard to understand, I have no idea what you are saying.

C#:
public void OnItemRemoved(InventoryModEvent e)
{
    Server.Broadcast(e.Player.Name + " took out: " + e.Item.Name + " Quanity: " + e.Item.Quantity)
}


public void GetEntityItems(Entity e)
{
    if (e.Inventory != null)
    {
        List<EntityItem> ItemsToRemove = new List<EntityItem>();
        foreach (var item in e.Inventory.Items)
        {
            if (item.Name == "??")
            {
                ItemsToRemove.Add(item);
            }
        }
        foreach (var x in ItemsToRemove)
        {
            // do something
        }
    }
}
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
You are really hard to understand, I have no idea what you are saying.

C#:
public void OnItemRemoved(InventoryModEvent e)
{
    Server.Broadcast(e.Player.Name + " took out: " + e.Item.Name + " Quanity: " + e.Item.Quantity)
}


public void GetEntityItems(Entity e)
{
    if (e.Inventory != null)
    {
        List<EntityItem> ItemsToRemove = new List<EntityItem>();
        foreach (var item in e.Inventory.Items)
        {
            if (item.Name == "??")
            {
                ItemsToRemove.Add(item);
            }
        }
        foreach (var x in ItemsToRemove)
        {
            // do something
        }
    }
}
Is it possible to check whether the player puts in the box with the name BoxLoot(clone) the object - say a weapon M4

Can I check - did the player the bandage - you want to make the system of thirst

And how do I get a list of the things in the chest?Want to do,that they drop after you break the chest and not destroyed along with him
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name);
    }
}

No Idea if this works, but It should.
C#:
public void On_EntityDestroyed(Entity e)
{
    if (e.Inventory != null)
    {
        foreach (var item in e.Inventory.Items)
        {
            item.Drop();
        }
    }
}
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name);
    }
}

No Idea if this works, but It should.
C#:
public void On_EntityDestroyed(Entity e)
{
    if (e.Inventory != null)
    {
        foreach (var item in e.Inventory.Items)
        {
            item.Drop();
        }
    }
}
If you also want the inventory name:

C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name + " to: " + e.Inventory.name);
    }
}
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
If you also want the inventory name:

C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name + " to: " + e.Inventory.name);
    }
}
I think the video will help to more accurately convey what I mean


to obtain the names of the box - which was added to M4 and check whether you used the bandage
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
I think the video will help to more accurately convey what I mean


to obtain the names of the box - which was added to M4 and check whether you used the bandage
Already told you.

No idea about the bandage.

C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name + " to: " + e.Inventory.name);
    }
}
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
Already told you.

No idea about the bandage.

C#:
public void On_ItemAdded(InventoryModEvent e)
{
    if (e.Player != null)
    {
        Server.GetServer().Broadcast(e.Player.Name + " added " + e.Item.Name + " to: " + e.Inventory.name);
    }
}
if(e.Inventory!=null)
{
foreach(var item in e.Inventory.Items)
{
item.Drop();
}
}
not working - things are removed from the chest
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Can you test this for me please?

P ut some items in the chest and do:

Server.GetServer().Broadcast(e.Inventory.Items.Length.ToString());

Tell me if it tells you any number or no.
 

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown
Can you test this for me please?

P ut some items in the chest and do:

Server.GetServer().Broadcast(e.Inventory.Items.Length.ToString());

Tell me if it tells you any number or no.
Putting 3,000 wood in the chest and killing him I got a value of 36
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
up - raising themes that were not resolved

It is impossible to assign a value to a property or indexer "IInventoryItem.condition" -- access read-only

how to remove choose 'read only'
Can't.
You'll have to find another method
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com

Brain

Member
Member
Dec 29, 2016
71
7
8
50
Parts Unknown