Jump to content

Why not working setTimer?


Turbe$Z

Recommended Posts

Posted (edited)
local countdown = 120
		G3 = guiCreateLabel(0.49, 0.67, 0.03, 0.02, tostring(countdown).." mp", true)
        guiSetFont(G3, "default-bold-small")    
		guiSetVisible(G3,false)

addEventHandler("onClientGUIClick",root,
	function ()
	if source == buttonGuest then
	removeEventHandler("onClientRender",root,a123)
	addEventHandler("onClientRender", root, dxhavendeg)
	guiSetVisible(buttonLogin,false)
	guiSetVisible(buttonRegister,false)
	guiSetVisible(buttonGuest,false)
	guiSetVisible(editPassword,false)
	guiSetVisible(editUsername,false)
setTimer(function () 
	countdown = countdown - 1 
	if countdown >= 0 then 
		guiSetText(G3, tostring(countdown)) 
	else 
		outputChatBox("asd")
	end 
end, 120000, 1000) 
	end
end
)

what wrong? :'( 

Edited by Turbo777

My Fun server:

560x95_FFFFFF_FF9900_000000_000000.png

My DD server:

n-560x95_FFFFFF_FFFFFF_000000_000000.png

Posted
3 minutes ago, Dimos7 said:

what exacly you want to do?

when i click on the button, show and start the timer from 120

My Fun server:

560x95_FFFFFF_FF9900_000000_000000.png

My DD server:

n-560x95_FFFFFF_FFFFFF_000000_000000.png

Posted (edited)
28 minutes ago, Turbo777 said:

end, 120000, 1000)

replace 1000 with 0 cuz there no such thing

0*

Edited by #BrosS

من أراد الفشل عليه بالنجاح

Posted
Just now, Turbo777 said:

but still not working :S 

setTimer(function () 
	countdown = countdown - 1 
	if countdown >= 0 then 
		guiSetText(G3, tostring(countdown)) 
	else 
		outputChatBox("asd")
	end 
end, 1000, 0) 

 

  • Like 1

من أراد الفشل عليه بالنجاح

Posted
1 minute ago, #BrosS said:

setTimer(function () 
	countdown = countdown - 1 
	if countdown >= 0 then 
		guiSetText(G3, tostring(countdown)) 
	else 
		outputChatBox("asd")
	end 
end, 1000, 0) 

 

the counter does not countdown :S 

sorry for my bad English:c

My Fun server:

560x95_FFFFFF_FF9900_000000_000000.png

My DD server:

n-560x95_FFFFFF_FFFFFF_000000_000000.png

Posted
local countdown = 120
		G3 = guiCreateLabel(0.49, 0.67, 0.03, 0.02, tostring(countdown).." mp", true)
        guiSetFont(G3, "default-bold-small")    
		guiSetVisible(G3,false)

addEventHandler("onClientGUIClick",root,
	function (button, state)
	if button == "left"and state=="up" and source == buttonGuest then
	removeEventHandler("onClientRender",root,a123)
	addEventHandler("onClientRender", root, dxhavendeg)
	guiSetVisible(buttonLogin,false)
	guiSetVisible(buttonRegister,false)
	guiSetVisible(buttonGuest,false)
	guiSetVisible(editPassword,false)
	guiSetVisible(editUsername,false)
setTimer(function () 
	countdown = countdown - 1 
	if countdown >= 0 then 
		guiSetText(G3, tostring(countdown)) 
	else 
		outputChatBox("asd")
	end 
end, 1000, 0) 
	end
end
)

try see if that work

  • Like 1

 

 

Posted
4 minutes ago, Turbo777 said:

the counter does not countdown :S 

sorry for my bad English:c

no it's working and i just tested it

try again with my code

من أراد الفشل عليه بالنجاح

Posted
1 minute ago, Dimos7 said:

after change the code do a restart to the resource to see if it works

Working, thank you! :D

  • Like 1

My Fun server:

560x95_FFFFFF_FF9900_000000_000000.png

My DD server:

n-560x95_FFFFFF_FFFFFF_000000_000000.png

  • Moderators
Posted
end, 1000, countdown) 

I do recommend this. There is no need for an infinity timer since you already know that it is going to stop at 0.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...