rateLimiter = rateLimiter or {} rateLimiter.last = rateLimiter.last or {} rateLimiter.interval = { default = 1.0, blocking = 0.3, } rateLimiter.myTime = function() local time = getTime() local seconds = time.hour*3600 + time.min * 60 + time.sec + time.msec/1000 return seconds end rateLimiter.Tried = function(action) local currenttime = rateLimiter.myTime() rateLimiter.last[action] = currenttime end rateLimiter.CanTry = function(action) local currenttime = rateLimiter.myTime() local interval = rateLimiter.interval[action] if not(rateLimiter.last[action]) then rateLimiter.last[action] = 0 end if not(interval) then interval = rateLimiter.interval.default end return (currenttime - rateLimiter.last[action]) > interval end------------------------------------------------------------------------
if CanTry("pt-announce-prismatic") then send("PT Santar has prismatic barrier!") Tried("pt-announce-prismatic") end
Comments