Set deployable entity that it can be picked up only by owner

Hello, is there please any way how to set test generator that it can be picked up with hammer only by owner? Thanks a lot

private bool CanPickupEntity(BasePlayer player, ElectricGenerator generator)
{
    return generator.OwnerID == 0;
}

The above code is an example of how to do it. Simple make an empty plugin and use that code :)

LDt7hBpCozsbUiV.png Ryz0r
private bool CanPickupEntity(BasePlayer player, ElectricGenerator generator)
{
    return generator.OwnerID == 0;
}

The above code is an example of how to do it. Simple make an empty plugin and use that code :)

wow great, is that one which can by only spawn by admin? Where can i find any tutorial for rust mods? That i dont have to ask for everything :( Thanks a lot

The guides on uMod should be more than enough to get you going. I'm feeling pretty nice today, so enjoy.

namespace Oxide.Plugins
{
    [Info("No Pickup Generator", "Ryz0r", "1.0.0")]
    [Description("Can't pickup Test Generator.")]
    public class NoPickupGenerator : RustPlugin
    {
        private bool CanPickupEntity(BasePlayer player, ElectricGenerator generator) => generator.OwnerID == 0;
    }
}​

thanks a lot, please what about cant loot/open?
that only entity who placed item can open/lootit?

How to update this code? (plugin PayForElectricity). That ItemBaseFlowRestrictor entity can by looted only by real owner (no friend, team or another guy authorized on cupboard) of parent entity generator.small

void OnLootEntity( BasePlayer player, ItemBasedFlowRestrictor entity )
		{
			BaseEntity parent = entity.GetParentEntity();
			if (parent != null && parent.ShortPrefabName == "generator.small")
			{
				PaidGenerator gen = PaidGenerator.FindById(entity.net.ID);
				if (gen == null)
				{
					gen = PaidGenerator.Create(parent.net.ID, entity.net.ID);
				}
				ShowUI(player, gen);
				CheckIfLooting(player);
			}
		}​
LDt7hBpCozsbUiV.png Ryz0r
private bool CanPickupEntity(BasePlayer player, ElectricGenerator generator)
{
    return generator.OwnerID == 0;
}

The above code is an example of how to do it.

I advise returning null instead of true to avoid hook conflicts when another plugin wants to prevent picking up an entity.
NKXTQs24ExGTuL8.jpg WhiteThunder
I advise returning null instead of true to avoid hook conflicts when another plugin wants to prevent picking up an entity.

hi, you mean null instead of 0?

No, like this:

private bool CanPickupEntity(BasePlayer player, ElectricGenerator generator)
{
    if (generator.OwnerID != player.userID)
    {
        // Entity is not owned by the player trying to pick it up, so return false to disallow pickup.
        return false;
    }

    // Entity is owned by the player trying to pick it up, so return null to allow the default vanilla behavior.
    return null;
}​