# dxDrawSpotLight (Client)

> Lights a cone for a single frame, without creating an element.

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

## Syntax

```lua
bool dxDrawSpotLight(float x, y, z, float dirX, dirY, dirZ, float radius, color color [, float cone = 30, float hardness = 0.5, float intensity = 1, float falloff = 4, float sourceRadius = 0.1, bool castShadow = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `x, y, z` | `float` | The light's position in the world, three numbers or a vec3. |
| `dirX, dirY, dirZ` | `float` | Where the light points. Three numbers or a vec3, finite and non-zero; it is normalised. |
| `radius` | `float` | Range in metres, above 0 and up to 1000. |
| `color` | `color` | Three numbers `r, g, b` (integers from 0 to 255) or a `tocolor` value. Alpha is ignored. |
| `cone` | `float` | Half the cone's opening, in degrees from its axis, above 0 and up to 90. *(default: `30`)* |
| `hardness` | `float` | Fraction of the cone lit fully, from 0 to 1. Anything above 0.99 counts as 0.99. *(default: `0.5`)* |
| `intensity` | `float` | Brightness multiplier, from 0 to 1000. At 1, a white light shines with an HDR radiance of 12. *(default: `1`)* |
| `falloff` | `float` | Exponent of the fade toward the radius, from 0.1 to 32. Higher values keep the light strong closer to its edge. *(default: `4`)* |
| `sourceRadius` | `float` | Radius of the bulb in metres, from 0 to the light's range. Left out, 0.1 or the range, whichever is smaller. *(default: `0.1`)* |
| `castShadow` | `bool` | Whether the light casts shadows. *(default: `false`)* |

## Returns

`true` if the light was queued for the frame. `false` when 256 lights are already queued, or with a wrong argument.

The light lasts one frame. A call made before the world is drawn (for example in `onClientPreRender` or `onClientRender`) lights that frame; one made after it lights the next. Calls made while no frame runs are dropped. Going over 256 lights in a frame logs a warning once, until a frame leaves room in the queue.

## Example

```lua
addEventHandler("onClientPreRender", root, function()
    local pos = getElementPosition(localPlayer)
    local a = math.rad(getElementRotation(localPlayer).z)
    dxDrawSpotLight(pos.x, pos.y, pos.z + 0.6, -math.sin(a), math.cos(a), -0.2, 30, 255, 250, 230, 20)
end)
```

### Coming from MTA

MTA has no dynamic lights.

## See also

- [createSpotLight (Client)](https://wiki.mymp.gg/en/createSpotLight.md): Creates a light that shines inside a cone, like a spotlight. The light exists on this client only.
- [dxDrawPointLight (Client)](https://wiki.mymp.gg/en/dxDrawPointLight.md): Lights a point in every direction for a single frame, without creating an element.
- [dxDrawRectLight (Client)](https://wiki.mymp.gg/en/dxDrawRectLight.md): Lights from a rectangle for a single frame, without creating an element.
- [onClientPreRender (Client)](https://wiki.mymp.gg/en/onClientPreRender.md): Fired every frame, after the world is simulated and before the world is drawn.
