Help with script

I’m running the fps module from the binaries forum, and it’s working great and all and I’ve customized the example script to remove welds on linux and then freeze the props.

[lua]require"fps" --loading module…

local pfps = 10
local tn = 1
hook.Add(“Think”,“Unlag”,function()
pfps = pfps + (math.Clamp(game.GetFPS()-pfps,-10,1)) --smooth fps making it more sensitive to drops
if tn>=33 then --issue command each 33 ticks, otherwise possible jerky motion
tn = 0
end
tn=tn+1
if pfps < 11 then
local Ent = ents.FindByClass(“prop_physics”)
for _,Ent in pairs(Ent) do
if Ent:IsValid() then
constraint.RemoveConstraints( Ent, “Weld” )
local phys = Ent:GetPhysicsObject()
phys:EnableMotion(false)

		end
	end
	local Ent = ents.FindByClass("prop_physics")
	local Wire = ents.FindByClass("gmod_wire_*")
	for _,Wire in pairs(Wire) do
		if Wire:IsValid() then
			local phys = Wire:GetPhysicsObject()
			phys:EnableMotion(false)
		end
	end
	for _,Ent in pairs(Ent) do
		if Ent:IsValid() then
			local phys = Ent:GetPhysicsObject()
			phys:EnableMotion(false)
		end
	end
	PrintMessage( HUD_PRINTTALK, "-SERVER- Removed welds to reduce lag!" );
end 

end)[/lua]

It’s working as is, but I want to make it run only if the servers fps drops below pfps for X amount of seconds. Can someone shed some light on this situation on how I would go about doing so?

Thanks in advance!
wtr

Here is a bit of pseudocode
[lua]
local X = 30
local CurT
if pfps < 11 then
if CurT then
if CurTime() > CurT + X then
CurT = nil
// Remove Shit
end
else
CurT = CurTime()
end
end
[/lua]

Wrote in the reply box I am sure their is a neater way to do it but this should give you the idea

Thank you very much King!