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?
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:
local t = CurTime()
timer.Create(“MyCooltimer”, 5, 10, function() print(CurTime() - t) end) – Print Elapsed time since timer was started
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:
// 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;
// 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
timer.create( curTime( glua ), 1 ) -> function( time )
print( time[ i ] );