CurTime() countdown?

Hi!
Im a little confused of how a countdown would work with CurTime… Does anyone know how I would do a countdown from 10 with CurTime()? Would it be something like a for loop +1ing a coundown variable against CurTime() or something?
Any ideas?
Thanks!

You would be better off just using timer.Create, but basically you save CurTime() in a variable, then later subtract CurTime() by your saved variable to find the time difference, example:

[lua]
function MyFunction()
local t = CurTime()
timer.Create(“MyCooltimer”, 5, 10, function() print(CurTime() - t) end) – Print Elapsed time since timer was started
end[/lua]

I just want to add, that CurTime() the amount of seconds since server start. Your question gives me the impression that you didn’t know that.

It’s great for many usages but an easy example:
[lua]
function ENT:Initialize()

 // when it's spawned, lets say it spawns with the server start,
 // then this would be maybe 6 (depends on how long it takes for it to spawn)
self.NextUse = CurTime() + 5;

end

function ENT:Use()

// Here we check if NextUse is more the current time.
// So, if we'd use this entity within 5 seconds of it spawning, it'd return false.
if ( self.NextUse > CurTime() )
	return false;
else
	// Now we put self.NextUse to 5 seconds, so this can't be used before another 5 seconds
	self.NextUse = CurTime() + 5;
end

end
[/lua]

timer.create( curTime( glua ), 1 ) -> function( time )
print( time[ i ] );
end