# dxCreateScreenSource (Client)

> Creates a screen source: an image that receives a copy of the game's screen on each `dxUpdateScreenSource`.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Screen drawing
- **URL**: https://wiki.mymp.gg/en/dxCreateScreenSource

## Syntax

```lua
texture|nil dxCreateScreenSource(int width, height)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `width, height` | `int` | Size in pixels, from 1 to 16384. The screen is stretched to fit. A vec2 also works. |

## Returns

The screen source, or `nil` when the size is outside 1 to 16384 or it could not be created.

## Example

```lua
local sx, sy = getScreenSize()
local screen = dxCreateScreenSource(sx / 4, sy / 4)

addEventHandler("onClientRender", root, function()
    dxUpdateScreenSource(screen)
    dxDrawImage(sx - sx / 4 - 20, 20, sx / 4, sy / 4, screen)
end)
```

### Note

On failure it returns `nil`, not `false`.

## See also

- [dxUpdateScreenSource (Client)](https://wiki.mymp.gg/en/dxUpdateScreenSource.md): Copies the game's screen into a screen source.
- [dxDrawImage (Client)](https://wiki.mymp.gg/en/dxDrawImage.md): Draws an image on the screen for one frame.
- [dxCreateRenderTarget (Client)](https://wiki.mymp.gg/en/dxCreateRenderTarget.md): Creates a render target: an image the dx functions can draw into and that can be used like any other image.
