createSpotLight
Client
Creates a light that shines inside a cone, like a spotlight. The light exists on this client only.
light|false createSpotLight(float x, y, z, float dirX, dirY, dirZ [, float radius = 15, color color = tocolor(255, 255, 255), float cone = 30, float hardness = 0.5])
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.default 15 |
| color | color | Three numbers r, g, b (integers from 0 to 255) or a tocolor value. Alpha is ignored.default tocolor(255, 255, 255) |
| 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 |
Returns
The created light element, or false if it could not be created.
Its source radius starts at 0.1 metres (or the range, if smaller); change it with setLightSourceRadius. A light outside the focused dimension or area is not drawn.
Example
local pos = getElementPosition(localPlayer)
local light = createSpotLight(pos.x, pos.y, pos.z + 6, 0, 0, -1, 20, 255, 240, 200, 25, 0.7)
setLightCastShadow(light, true)Coming from MTAMTA has no dynamic lights. To light a single frame without creating an element, use
dxDrawSpotLight.