ENT:USe one player at a time

Is there anyway to make it so if another player has pressed E on an entity it will send a command to the player who also wants to press the entity saying something like " Entity currently in use. "
not sure if that makes sense but all im wanting to do is make it do Something if another players already pressed e on it. is there anyway at all to do this?

Should work



function ENT:Use(activator, caller)
	if self.inUseBy and self.inUseBy != caller then
		caller:ChatPrint('This entity is currently in use by ' .. self.inUseBy:Nick())
		return
	end

	self.inUseBy = caller

	timer.Simple(2, function()
		self.inUseBy = nil
	end)
end


I have do what you said and its working but it still continues to do the rest of my code, for example some of my code would be


function ENT:Use( activator, caller )
	if self.inUseBy and self.inUseBy != caller then
		caller:ChatPrint('This entity is currently in use by ' .. self.inUseBy:Nick())
		return
	end

	self.inUseBy = caller

	timer.Simple(2, function()
		self.inUseBy = nil
	end)
	net.Start("DrawTheREaaalDerma")
	net.Send(caller)
	caller:Freeze(true)
	timer.Simple(1, function()
		self:EmitSound( Sound( "physics/concrete/concrete_break2.wav" ), self:GetPos(), 1, CHAN_AUTO, 1, 75, 0, 100 )
	end)

after it has printed This entity is currently in use by ’ … self.inUseBy:Nick()) it will continue to start that net message and emit those sounds, anyway to stop that?

Try remove



timer.Simple(2, function()
	self.inUseBy = nil
end)


And you must send something to server when player close the menu, i think, to unfreeze and remove tag from an entity

works thanks, legend