1. Is there a way to get the default item drop position and item drop velocity? I'm not seeing it in the assembly.

    I see the Vector3 input I'm just trying to get the default vectors for the .Drop call.

    End goal is to shoot flaming rocks out from the player.
     
  2. use it:

    Code:
    item.Drop(player.eyes.position, player.eyes.BodyForward() * 2f);
     
  3. Getting:

    Code:
    | Failed to call hook 'OnItemDropped' on plugin 'Fireball 0.0.1' (NullReferenceException: Object reference not set to an instance of an object)
     
  4. It's not about vectors or positions, it's about objects.
    Item or player is null
     
  5. I'm doing the following

    Code:
     void OnItemDropped(Item item, BaseEntity entity)
            {
                if (item.info.shortname == "rock")
                {
                    BasePlayer player = item.GetOwnerPlayer();
                    Item newitem = ItemManager.Create(ItemManager.FindItemDefinition("rock"), 1, 0uL);
                    item.Remove(0f);
                    item.RemoveFromContainer();
                    Vector3 velocity = new Vector3(0, 0, 0);
                    newitem.Drop(player.transform.position, player.GetDropVelocity());
                    return;
                }
                else
                {
                    return;
                }        }
    
     
    Last edited by a moderator: Apr 21, 2017
  6. 1. Why do you create a new object, is not it easier to throw off the existing?

    Code:
    void OnItemDropped(Item item, BaseEntity entity)
            {
                if (item.info.shortname == "rock")
                {
                    BasePlayer player = item.GetOwnerPlayer();
                    item.Drop(player.eyes.position, player.eyes.BodyForward() * 2f);
                }
            }
    
    2. Item create is not meaning it's will be an object in worl. So you need to wait before drop it:

    Code:
    void OnItemDropped(Item item, BaseEntity entity)
            {
                if (item.info.shortname == "rock")
                {
                    BasePlayer player = item.GetOwnerPlayer();
                    Item newitem = ItemManager.Create(ItemManager.FindItemDefinition("rock"), 1, 0uL);
                    item.Remove(0f);
                    item.RemoveFromContainer();
                    NextTick(() =>
                    {
                        newitem.Drop(player.eyes.position, player.eyes.BodyForward() * 2f);
                    });
                }
            }
     
  7. Still getting null reference exception :(

    Even with just the long version of what you posted. Is it because the hook is called after the item is dropped and thus it has no owner?
     
  8. I've done some testing and am just hitting a rode block here. It seems that the player will always be null as the item has dropped and does not have an owner anymore...

    I could be wrong but is this something intended with the hook?
     
  9. Finally figured this one out.

    I was calling the BasePlayer incorrectly. Now I can't mark this as solved 0.o