Solved No looting sleepers

Discussion in 'Plugin Requests' started by Killzone, Mar 29, 2015.

  1. Clear() and EndLooting() do not cancel the loot interface for me.

    Code:
    function PLUGIN:OnPlayerLoot( sourceplayerloot, target )
      if(target:GetComponent("BasePlayer")) then
        local sourcePlayer = sourceplayerloot:GetComponent("BasePlayer")
          sourceplayerloot:Clear()
          rust.SendChatMessage( sourcePlayer, "<color=#FFD700>Looting sleepers on this server is disabled</color>" )
      end
    end
     
  2. I'm also looking for something similar, I would like to disable looting of sleeping admins as sometimes we have extra items in our inventory that we used commands to obtain that if we were looted would give an unfair advantage to the player looting us.
     
  3. You need to account for a slight delay for the loot window to actually open before closing it other wise you would just clear a cleared playerloot before anything is added to it.
    This should do what you want:
    Code:
    function PLUGIN:OnPlayerLoot(source, target)
        if target:GetComponent("BasePlayer") then
            timer.NextFrame(function() source:Clear() end)
            player = source:GetComponent("BasePlayer")
            rust.SendChatMessage( player, "<color=#FFD700>Looting sleepers on this server is disabled</color>" )
        end
    end
     
  4. Thank you, that works.
     
  5. Is the a way to track is looting menu is still opened? Or hook for loot menu close?
     
  6. There isn't a hook available to check when it's closed, you can however check if someone is looting with:
    Code:
    player.inventory.loot.IsLooting()
     
  7. But can it be called as detect of SOMEONE looting SOME inventory on inventory side?
    Like inventory.IsLootingBy() : BasePlayer?