1. Can anyone help me with some code to protect boxes and stashes of a specific player from damage ?
     
  2. I'm not home atm but you could use OnEntityTakeDamage, check for the type of object being damaged, use entityowner to check for owner, scale damage accordingly.
    There are plenty of examples on how to check the owner with entity owner, I can't think of any of my own off the top of my head but I think there is one on the overview.
    You can see how to scale damage in TeamDeathmatch /Slasher/ChopperSurvival
    [DOUBLEPOST=1455176191,1455132843][/DOUBLEPOST]
    Code:
     List<string> PlayersWhoseBoxesCantBeDamaged = new List<string>(); // For this example I am using a List, the strings in the list would be player.UserIDString. You can add players in many different ways, and it doesn't necessarily have to be a list.        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo) // Called when a entity takes damage
            {
                try
                {
                    if (entity is StorageContainer && hitinfo.Initiator is BasePlayer) // Player is attacking a storage container
                    {
                        var box = entity.GetComponent<StorageContainer>();
                        var owner = FindOwner(box); // Find the owner of the box using EntityOwner
                        if (owner != "") // Make sure there is a owner before proceeding
                        {
                            if (PlayersWhoseBoxesCantBeDamaged.Contains(owner))
                            {
                                hitinfo.damageTypes.ScaleAll(0); // Scales all damage types                          
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            private string FindOwner(BaseEntity entity) // Pinched from one of Calytic's plugins to use as a example on how to call from EntityOwner
            {
                object returnhook = null;
                string ownerid = "";
                returnhook = EntityOwner?.Call("FindEntityData", entity);
                if (returnhook != null)
                {
                    if (!(returnhook is bool))
                    {
                        ownerid = Convert.ToString(returnhook);
                    }
                }
                return ownerid; // Returns the owner ID as a string since that is what the function type is
            }
     

  3. Wow! Awesome reply. Thanks alot.
     
  4. You can now just check for the owner without EntityOwner as Rust now saves the owner itself.
    Code:
    if (AwesomeSteamIDList.Contains(entity.SteamID) && entity is StorageContainer)
       // Block Damage
    
     
  5. Thanks !
     
  6. No problem :)
     
  7. I'm having some problems could you give a more complete example of this?
     
  8. Code:
    List<ulong> playersWithProtectedBoxes = new List<ulong>();void OnEntityTakeDamage(BaseCombatEntity vic, HitInfo info)
    {
    if (vic == null || vic.SteamID == null)
    return;if (playersWithProtectedBoxes.Contains(vic.SteamID) && vic is StorageContainer)
    info.damageTypes.scaleAll(0);
    } 
     
  9. I get this error:
    Code:
    Type `BaseCombatEntity' does not contain a definition for `SteamID' and no extension method `SteamID' of type `BaseCombatEntity' could be found. Are you missing an assembly reference?
     
  10. Yea sorry, wrote that quickly this morning on mobile. I will write you a working example once I am at home.
     
  11. Can you still help me with this?
     
  12. Code:
    List<ulong> playersWithProtectedBoxes =[URL='http://www.google.com/search?q=new+msdn.microsoft.com']new[/URL] List<ulong>();void OnEntityTakeDamage(BaseCombatEntity vic, HitInfo info)
    {
    if(vic ==null|| vic.ToPlayer() ==null)
        return;if(playersWithProtectedBoxes.Contains(vic.ToPlayer().userID) && vic is StorageContainer)
        info.damageTypes.scaleAll(0);
    }
     
  13. Thanks for the help on this !