1. Code:
    void OnPlayerLoot(PlayerLoot inventory, BasePlayer target)
    {
     if (TeamData.ContainsKey(target))
      inventory.Clear();
    }
    Code:
    [Error] Failed to call hook 'OnPlayerLoot'
    (InvalidCastException: Cannot cast from source type to destination type.)
     
  2. What's the TeamData dict? I mean, is it Dictionary<BasePlayer, string>?
     
  3. yes yes yes
     
  4. Code:
    void OnPlayerLoot(PlayerLoot inventory, BasePlayer target)
    {
    if(TeamData.ContainsKey(target))
      target.inventory.Strip();
    }
    
     
  5. It to clear inventory of the player (target)
    May be I try:
    Code:
    inventory.entitySource.ToPlayer().EndLooting();
     
  6. Didn't help :((
    May be BasePlayer not BasePlayer? or i'm don't know in what's problem
     
  7. I haven't read the whole conversation but instead of:
    Code:
    inventory.entitySource.ToPlayer().EndLooting();
    try this:
    Code:
    BasePlayer player = inventory.GetComponent<BasePlayer>();if (player == null) return;player.EndLooting();
     
  8. Code:
    [Error] Failed to call hook 'OnPlayerLoot' (InvalidCastException: Cannot cast from source type to destination type.)
    I don't understand in what a problem.

    EDIT: I rename hook to
    Code:
    void OnPlayerLoot(PlayerLoot inventory, BaseEntity entity)
    Errors weren't
     
    Last edited by a moderator: Dec 21, 2015
  9. Code:
    void OnPlayerLoot(PlayerLoot inventory, BaseEntity entity)
            {
                if (entity is BasePlayer)
                {
                    BasePlayer target = entity.ToPlayer();
                    if (TeamData.ContainsKey(target))
                    {
                        target.EndLooting();
                        inventory.Clear();
                        PrintToChat(target, "Your inventory grabbed");
                    }
                }
            }
    the message shows, and Loot not to stop
     
  10. entity isn't the player! It's the thing you are looting. To get the player who is looting you have to write the following:
    Code:
    BasePlayer target = inventory.GetComponent<BasePlayer>();