1. Hey.

    I'm trying to stop players from being able to loot other dead players' bodies.
    Could someone help me with this?

    I also need to be able to send a message to the looter saying that they can't loot that person or whatever.

    I'm using C# btw.

    Thanks,
    PsychoTea
     
  2. Wulf

    Wulf Community Admin

    Or look at my NoSleepers or LootProtection plugins.
     
  3. Thanks!
    [DOUBLEPOST=1447618045][/DOUBLEPOST]Ah. I have a problem. CanLootPlayer is for sleeping players, I need it for dead players' bodies. If there is a way to remove certain players' bodies when they die that would be even better.
     
  4. Code:
    void OnPlayerLoot(PlayerLoot inventory, BaseEntity target)
    {
    Puts("OnPlayerLoot works!");
    }
    There are 3OnPlayerLoot hooks you can check the others too if you want.
     
  5. Thanks; how would I get the looter?
     
  6. Using PlayerLoot. Search around in that class using a decompiler and you'll find it.
     
  7. Calytic

    Calytic Community Admin Community Mod

    Code:
    (BasePlayer)inventory.entitySource
     
  8. Hmm. I'm having a problem where it's saying "Failed to call hook 'OnPlayerLoot'...(InvalidCastException: Cannot cast from source type to destination type.)"
    Here's my code
    Code:
    void OnPlayerLoot(PlayerLoot inventory, BaseEntity target)
            {
                BasePlayer looter = (BasePlayer)inventory.entitySource;
                if (storedData.playerClass[target.ToPlayer().userID] == "god")
                {
                    SendReply(looter, RAPrefix + "You're not allowed to loot god class players!" + RASuffix);
                    inventory.Clear();
                }
            }
    
     
  9. Calytic

    Calytic Community Admin Community Mod

    Try this instead

    Code:
    inventory.GetComponent<BasePlayer>()
     
  10. Thanks! That works :) Another problem tho, how would I get BasePlayer from BaseEntity?
     
  11. Wulf

    Wulf Community Admin

    var player = BaseEntity as BasePlayer;
     
  12. I already tried that but it gives me an NRE :/
     
  13. then that entity is not a player.
     
  14. But it's happening right when I open a (dead) players body, could that be why? I just need the userID of the body being looted.
     
  15. Code:
    if (entity.GetComponent<PlayerCorpse>() != null)
        Puts(entity.GetComponent<PlayerCorpse>().playerSteamID.ToString());
     
  16. Awesome thanks. That's working. But I'm confused as to how to close the inventory. I thought you'd use inventory.Clear() but that's not working.
     
  17. player.EndLooting()
    Maybe you should take a look at the assembly before asking ;)
     
  18. I had a look under PlayerLoot and Inventory but couldn't find anything :p Must've been looking in the wrong place. Thanks!
     
  19. yes. BasePlayer.