Finding who dropped an item?
Hello, i am trying to figure out how to make it so you cannot drop items so this is my idea.

void OnItemDropped(Item item, BaseEntity entity)
{
// item.MoveToContainer(entity.GetPlayerOwner.inventory);
}

So the idea is to get the owner then move the item back to the players inventory however i dont know how to get the player that dropped it so im a bit stuck :)
 

Responses are apprechiated! Regardless of how it contributes <3
Isn't the entity parameter to that function the player that dropped the item?

Merged post

Oh, did you mean how to check if entity is a BasePlayer? Something like this then.

void OnItemDropped(Item item, BaseEntity entity) {
    BasePlayer player = entity as BasePlayer;

    if(player != null) {
        player.inventory.GiveItem(item);
    }
}​
@andrew2085 entity, in this case, is the world item while the item is the item in the inventory before it is dropped. So unless the player is dropping another player out of their inventory that will not work.

You can get the owner from the item itself using GetOwnerPlayer().

        void OnItemDropped(Item item, BaseEntity entity)
        {
            var player = item.GetOwnerPlayer();

            if (player == null)
            {
                return;
            }

            entity.Kill();
            player.inventory.GiveItem(item);
        }​
Lol damn! I did GetPlayerOwner which is why i was so confused thanks :)

Merged post

Is there any wikis for functions that i can use because i am very limited by the fact that i have to ask people for help to figure out stuff.
5dc0d18fbfe04.png Stromic
Is there any wikis for functions that i can use because i am very limited by the fact that i have to ask people for help to figure out stuff.

You can open the game's DLLs using a .NET decompiler to see what is available.

Yeah i figured it out :P I found it on youtube but thank you Wulf! <3