How to get the time left in a timer

How do you get the time left in a timer. I want to make a timer that uses the time left in another timer as its time.
Also, would this be the right code?
[lua]
function GM:PlayerDeathThink(ply)
timer.Simple(whatever the time left is, Spawn)
[/lua]

well you could use a variable in the other timer that starts as its entire time and goes down each time the timer uses its function.

Use CurTime()

Could I use
[lua]
----------Initialize----------
function GM:Initialize() --When the server initializes
roundover = false --Set “roundover” to false
GM:AllFreeze() --Run the function “GM:AllFreeze”
timer.simple(10, GM:RoundStart) --Set a timer to run “GM:RoundStart” in ten seconds

end

function GM:RoundEnd() --When this function is run
timer.simple(10, GM:RoundStart) --Set a timer to run “GM:RoundStart” in ten seconds
roundover = true --Set “roundover” to true
GM:AllFreeze() --Run the function “GM:AllFreeze”

end

function GM:AllFreeze() --When this function is run

for _, ply in ipairs( player.GetAll() ) do --Get all players and 
	ply:Freeze( true ) --Freeze them
	
end

end

function GM:AllUnFreeze() --When this function is run

for _, ply in ipairs( player.GetAll() ) do --Get all players and
	ply:Freeze( false ) --Un freeze them
	
end

end

function GM:PlayerDeathThink() --Every frame during death

if roundover = false then --If "roundover" is false then
	GM:CheckAllDead() --Run the function "GM:CheckAllDead"
	
end
	
if roundover then --If "roundover" is true then
	GM:AllSpawn() --Run the function "GM:AllSpawn"
	
end

end

function GM:RoundStart() --When this function is run
GM:AllUnFreeze() --Run the function “GM:AllUnFreeze”
GM:AllSpawn() --Run the function “GM:AllSpawn”
roundover = false --Set “roundover” to false
timer.simple(500, GM:RoundEnd) --Set a timer to run “GM:RoundEnd” in 500 seconds

end

function GM:AllSpawn() --When this function is run

for _, ply in ipairs( player.GetAll() ) do --Get all players and
	ply:Spawn() --Respawn them
	
end

end

function GM:CheckAllDead() --When this function is run

for _, ply in ipairs( player.GetAll() ) --Get all players and
	
	if ply:Alive() = false then --If they are all dead
		GM:RoundEnd() --Run the function "GM:RoundEnd"
		
	end

end
[/lua]

Clearly I misunderstood the question in the OP it seemed like you asked how to get the time that was left in a timer and why don’t you test the code and find out.

Yeah, I just came up with using a variable “roundover” in GM:PlayerDeathThink, to tell it whether the player whether he can spawn of not. Sorry. By the way, good job on actually helping someone for once.

Is it just me or the last 2 loops should not be ipairs but just normal pairs.

[editline]20th March 2011[/editline]

Infact, all should be pairs and not ipairs.

Ipairs is for numbers
Pairs is for anything else and numbers

I used some code from the wiki, I don’t really understand how to do something to all players.

Ok, well for future reference ipairs is for numbers only and pairs is for anything.

Does that code (ignoring the ipairs thingy) look like it will work?

ipairs is for sequential numerical indices, which player.GetAll() uses.

Didn’t really understand that. Does that mean I SHOULD use ipairs?

If the table keys are like:
1
2
3
4
5
6
7
etc. Then ipairs. else
pairs.

You learn a new thing every day.

So which should I use?

ipairs, but the difference is negligible.
When in doubt use pairs.

ipairs is used for indexing numerical tables, and you want it to loop through the table in order of keys(0, 1, 2, 3, 4, etc)
pairs just goes psuedo-randomly(it seems) but don’t worry, it goes through the whole table

Just like ralle105 said, you should use pairs when in doubt(for me most of the time ^^), I haven’t used ipairs yet lol…

This clearly proves my point that people don’t learn how to do anything by c&ping code together in the hope it works