Lua Pause

Hi, just making a simple script but came to a point were i need to pause. I googled but there was no Gmod specific so how would i do a quick wait like 1/2 a second?



timer.Simple(0.5, function()

-- unicorns
end)


Don’t google…

Lua doesn’t have a pause function.

There is no concept of pause in the game, unless you really want to freeze the player’s game for half a second.

What do you want to do anyway?

sv_pausable 1
pause
this is something else but it works

http://misc.diamondbuild.info/C++/gm_sleep.zip

[editline]10:46AM[/editline]

An example is included.

I’m using it to have a slight [pause in between each bullet in a burst round. the 1/2 a second was just an example.

Oh, you don’t want gm_sleep then.

Use a timer.Simple.

How would i use that in SWEP:PrimaryAttack to delay each when each bullet is shot?


self.Weapon:SetNextPrimaryFire(CurTime() + 1)

1 is delay in seconds

thats in between bursts. i have a for loop that shoots 3 bullets in the PrimaryFire function and i just need a little pause before the loop redoes the code.