Determining Entity Owner?

I’m making an entity for DarkRP, and in it’s init.lua I’m trying to design it so that only the entity’s owner can press E on it.

Here’s what I have.

[lua]function ENT:Use(activator,caller)

if self.dt.owning_ent then

GAMEMODE:Notify(activator, 1, 4, "You have recieved $"..rand.." for re-selling your stove .")

	GAMEMODE:Notify(activator, 1, 4, "Only "..self.dt.owning_ent.." can pick this up.")

end [/lua]

Any help is appreciated, thank you!

You get the owner (if set) in another way in DarkRP now.
This might be helpful:


if self:GetOwner() == activator then

If your using self:SetOwner(PLAYER)


self.OwnedBy = PLAYER

if self.OwnedBy and self.OwnedBy == activator then

Well, in your code you are checking if owner exists, instead of checking if hes the one using the entity.
Try repleacing that part on line 3 with [lua]if IsValid(self.dt.owning_ent) and self.dt.owning_ent == activator then[/lua]