Global server 'use key' timer. No spamming use on food, or holding it down and activating tons of entities at once?

Is this something I have to do in the entities directly or can I make a script that prevents anyone from giving the command +use for more than 0.1 seconds every 5 seconds?
I don’t want people to be able to press E on a pile of food in my darkrp server and eat all of it, or consume all of a drug, or spam doors to keep someone else from opening them.

Use the PlayerUse hook

[lua]
–Typed just now, untested, example only

hook.Add(“PlayerUse”, “PreventUseSpam”, function(ply,ent)
if ply.LastUseTime then
local elapsed = CurTime()-ply.LastUseTime
if elapsed>1 then --was their last use greater than 1 second ago?
ply.LastUseTime = CurTime()
return true --the delay has expired, they can use it
end
return false --dont let them use it
else
ply.LastUseTime = CurTime()
return true --let them use it the first time
end
end)[/lua]