- Documentation
- Server functions
- createLight
Function
createLight
Creates a light element: a point light (type 0, shines in all directions) or a spot light (type 1, with a direction), with a radius and colour.
Syntax
element createLight(int lightType, float x, float y, float z [, float radius = 3, int r = 255, int g = 255, int b = 255, float dirX = 0, float dirY = 0, float dirZ = 0, bool createsShadow = false])Arguments
lightTypeint- 0 = point, 1 = spot.
xfloat- Light X.
yfloat- Light Y.
zfloat- Light Z.
radiusfloat, optional = 3- Radius in metres.
rint, optional = 255- Red.
gint, optional = 255- Green.
bint, optional = 255- Blue.
dirXfloat, optional = 0- Direction X (spot).
dirYfloat, optional = 0- Direction Y.
dirZfloat, optional = 0- Direction Z.
createsShadowbool, optional = false- Whether it casts shadows.Not in MTA:SA
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
createLight(int lightType, float posX, float posY, float posZ, float radius = 3, int r = 255, int g = 0, int b = 0, float dirX = 0, float dirY = 0, float dirZ = 0)Returns
A light element, or false.
Example
local lamp = createLight(0, 2495, -1665, 16, 8, 255, 200, 120)
Notes
The light lights up the ground, walls, vehicles and characters within radius for every player (including players who join later), and setLightColor and setLightRadius change it straight away. The beam itself is not visible in the air, because the game has no volumetric fog. The cone (type 1) is 40°; without a direction it points down.
See also
setLightColorChanges the light colour.setLightRadiusChanges the light radius (0-255 m).createSearchLightCreates a searchlight beam: a real Unreal spot light shining from a start point to an end point, like a police helicopter searchlight or stadium lights. The cone width comes from the end radius and the distance; brightness adjusts itself to the beam length. Everyone in the same interior and dimension sees it.