---
name: "sleep"
type: command
status: ok
groups: ["Program Flow"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/sleep
revid: 370495
updated: 2024-12-26T17:40:41Z
---

# sleep

*Command · Program Flow · Arma 3 v0.50 · introduced in Armed Assault v1.00*

## Description

Suspends code execution for given [time](../commands/time.md) in seconds. The sleep precision is given by a framerate, the delay given is the minimal delay expected. Must be called inside of a context which is interruptible, i.e. a [script](../topics/Script_Handle.md) executed by [execVM](../commands/execVM.md) or [spawn](../commands/spawn.md).

> [!NOTE]
> - this command will suspend the code for ***at least*** the given amount of time, and can be way more if the [script scheduler](../topics/Scheduler.md) is busy.
> - this command will suspend the script as the game gets paused in single player (and will resume with it). To avoid this, use [uiSleep](../commands/uiSleep.md).

## Syntax

```sqf
sleep delay
```

**Parameters:**

- `delay`: [Number](../topics/Number.md) - in seconds. Negative values will not be considered.

**Returns:** [Nothing](../topics/Nothing.md)

## Examples

### Example 1

```sqf
0 spawn {
    sleep 5;
    hint "after (at least) 5 seconds...";
};
```

### Example 2

```sqf
sleep 5 + random 10;    // incorrect - will only sleep for 5 seconds, as it will be interpreted as (sleep 5) (+(random 10))
sleep (5 + random 10);    // correct
```

## See also

[time](../commands/time.md) · [uiSleep](../commands/uiSleep.md) · [waitUntil](../commands/waitUntil.md) · [canSuspend](../commands/canSuspend.md) · [execVM](../commands/execVM.md) · [spawn](../commands/spawn.md) · sleep vs uiSleep · [Control Structures](../topics/Control_Structures.md)

## Community notes

**CrashDome** — 2006-12-20

Sleep suspends both SQF functions and SQF scripts. In functions, the calling script is still in suspension due to waiting for a return from the [call](../commands/call.md) command. The game engine will continue, however. See Function for more detail.

---

**Kronzky** — 2007-02-12

Sleep durations between .0005 and .02 will cause the same delay (roughly .02 seconds).

Delays of .0005 and less have **no** effect (i.e, the sleep call will return immediately).

---

**Sbsmac** — 2007-02-13

The comment above is a little misleading. The game engine appears to work by processing frames and then checking to see whether scripts are available to execute.
Sleep causes the script/function to be suspended until at least the specified time has elapsed.
To wait for the next frame, or give other scripts a chance to run, use Sleep 0.001.

---

**Inkompetent** — 2007-06-16

For scripts called by the [Init Event Handler](../topics/Event_Handlers.md#init) the first sleep command will suspend the script at the briefing screen at the start of a mission. The script will continue after the briefing screen, when actually "in game".

<sub>Source: [BI Community Wiki — sleep](https://community.bistudio.com/wiki/sleep) (revision 370495).</sub>
