Wait x seconds in lua client script GARRYSMOD

Hello, i wonder how i can wait in a lua garrysmod client script.


How is that possible?

Look into timer.Simple or timer.Create, I think

Yes that’s on the server side… But on the client side ?

Timers can be used serverside and clientside.

How is that possible? My timers i created are not in the IF (SERVER) statement or IF (CLIENT) …
So you can put the timer in the client statement?
Any examples plz :slight_smile:

timer.Simple( 20, function()
– Runs after 20 seconds
end )

timer.Create( “Name”, 5, 0, function()
– Runs every 5 seconds
end )

timer.Destroy( “Name” ) – Destroys the timer called Name

These can be either serverside or clientside.

function ShowTextCountdown(msg1, msg2, delay, times)
timer.Create(“ShowTextCountdown”, tonumber(delay), tonumber(times) or 1, function()

Would do the same thing both clientside and serverside. You would then do something like this:
ShowTextCountdown(“please wait a few seconds”, “thx for waiting a few seconds”, 5, 1)
– This would first print “please wait a few seconds”, then 5 seconds later print “thx for waiting a few seconds” (The 1 at the end is optional, it will specify how many times the timer will be ran.