diff --git a/MTA_SA_SCRIPTING_DOCUMENTATION.md b/MTA_SA_SCRIPTING_DOCUMENTATION.md new file mode 100644 index 00000000..e39dd659 --- /dev/null +++ b/MTA_SA_SCRIPTING_DOCUMENTATION.md @@ -0,0 +1,5918 @@ +# Multi Theft Auto: San Andreas - Lua Scripting Documentation + +**Generated on:** 2025-12-08 21:55:48 UTC + +**Document Purpose:** AI Knowledge Base for MTA:SA Lua Scripting + +--- + +## Table of Contents + +1. [Introduction](#introduction) +2. [Overview](#overview) +3. [Statistics](#statistics) +4. [Functions](#functions) +5. [Events](#events) +6. [Elements](#elements) +7. [Quick Reference](#quick-reference) + +--- + +## Introduction + +This document contains comprehensive documentation for Multi Theft Auto: San Andreas (MTA:SA) Lua scripting API. It includes detailed information about all available functions, events, and elements that can be used when developing scripts/resources for MTA:SA servers. + +**Multi Theft Auto: San Andreas** is a multiplayer modification for Grand Theft Auto: San Andreas that allows players to create custom game modes, resources, and server-side/client-side scripts using the Lua programming language. + +--- + +## Overview + +MTA:SA provides a powerful Lua scripting API that allows developers to: + +- Create custom game modes and resources +- Handle server-side and client-side logic +- Interact with game elements (players, vehicles, objects, etc.) +- Respond to game events +- Create user interfaces +- Manage permissions and access control +- Integrate with databases and external services + +The API is divided into three main categories: + +1. **Functions** - Callable functions to perform actions and retrieve information +2. **Events** - Event handlers that respond to game actions +3. **Elements** - Game objects and entities that can be manipulated + +--- + +## Statistics + +| Category | Count | +|----------|-------| +| Total Functions | 1403 | +| Total Events | 220 | +| Total Elements | 62 | +| Function Categories | 52 | +| Event Categories | 19 | +| Element Categories | 21 | + +### Function Categories + +- ACL +- Account +- Admin +- Announcement +- Audio +- Blip +- Browser +- Building +- Camera +- Clothes_and_body +- Colshape +- Cursor +- Database +- Discord +- Drawing +- Effects +- Element +- Engine +- Event +- Explosion +- File +- Fire +- GUI +- HTTP +- Input +- Light +- Map +- Marker +- Module +- Object +- Output +- Path +- Ped +- Pickup +- Player +- Projectile +- Radar_area +- Resource +- SVG +- Searchlight +- Server +- Settings_registry +- Team +- Text +- UTF8_Library +- Utility +- Vehicle +- Water +- Weapon +- Weapon_creation +- World +- XML + +### Event Categories + +- Account +- Browser +- Client +- Colshape +- Element +- Input +- Marker +- Object +- Other +- Ped +- Pickup +- Player +- Projectile +- Resource +- Server +- Sound +- Vehicle +- Weapon +- Weapon_creation + +### Element Categories + +- ACL +- Account +- Audio +- Ban +- Browser +- DB +- Discord +- Drawing +- Engine +- Entity +- File +- GUI +- Matrix +- Resource +- Root +- Server +- Team +- Text +- Timer +- Vector +- XML + +--- + +## Functions + +Functions are the primary way to interact with the MTA:SA API. They allow you to create, modify, and query game elements and perform various operations. + + +### ACL Functions + +*25 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 20 more functions in this category* + +--- + + +### Account Functions + +*25 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 20 more functions in this category* + +--- + + +### Admin Functions + +*18 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 13 more functions in this category* + +--- + + +### Announcement Functions + +*7 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 2 more functions in this category* + +--- + + +### Audio Functions + +*41 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 36 more functions in this category* + +--- + + +### Blip Functions + +*12 functions in this category* + +### createBlip + +**Description:** This function creates a [[blip]] element, which is displayed as an icon on the client's radar. + +**Parameters:** + +- `x` (float): The x position of the blip, in world coordinates. +- `y` (float): The y position of the blip, in world coordinates. +- `z` (float): The z position of the blip, in world coordinates. +- `icon` (int): The icon that the radar blips should be. Default is 0. Valid values can be seen at [Radar Blips](/reference/ID_Lists/Blips). +- `size` (int): The size of the radar blip. Only applicable to the Marker icon. Default is 2. Maximum is 25. +- `r` (int): The amount of red in the blip's color (0-255). Only applicable to the Marker icon. Default is 255. +- `g` (int): The amount of green in the blip's color (0-255). Only applicable to the Marker icon. Default is 0. +- `b` (int): The amount of blue in the blip's color (0-255). Only applicable to the Marker icon. Default is 0. +- `a` (int): The amount of alpha in the blip's color (0-255). Only applicable to the Marker icon. Default is 255. +- `ordering` (int): This defines the blip's Z-level ordering (-32768-32767). Default is 0. +- `visibleDistance` (float): The maximum distance from the camera at which the blip is still visible (0-65535). +- `visibleTo` (element): This defines which elements can see the blip. Defaults to visible to everyone. See [[Visibility]]. + +**Returns:** + +Returns an element of the [[blip]] if it was created successfully, **false** otherwise. +- blip|false: created-blip + +### createBlipAttachedTo + +**Description:** This function creates a [[blip]] that is attached to an [[element]]. This blip is displayed as an icon on the client's radar and will 'follow' the element that it is attached to around. + +**Parameters:** + +- `elementToAttachTo` (element): The [[element]] to attach the blip to. +- `icon` (int): The icon that the radar blips should be. Default is 0. Valid values can be seen at [Radar Blips](/reference/ID_Lists/Blips). +- `size` (int): The size of the radar blip. Only applicable to the Marker icon. Default is 2. Maximum is 25. +- `r` (int): The amount of red in the blip's color (0-255). Only applicable to the Marker icon. Default is 255. +- `g` (int): The amount of green in the blip's color (0-255). Only applicable to the Marker icon. Default is 0. +- `b` (int): The amount of blue in the blip's color (0-255). Only applicable to the Marker icon. Default is 0. +- `a` (int): The amount of alpha in the blip's color (0-255). Only applicable to the Marker icon. Default is 255. +- `ordering` (int): This defines the blip's Z-level ordering (-32768-32767). Default is 0. +- `visibleDistance` (float): The maximum distance from the camera at which the blip is still visible (0-65535). +- `visibleTo` (element): This defines which elements can see the blip. Defaults to visible to everyone. See [[Visibility]]. + +**Returns:** + +Returns an element of the [[blip]] if it was created successfully, **false** otherwise. +- blip|false: created-blip + +### getBlipColor + +**Description:** This function will tell you what color a [[blip]] is. This color is only applicable to the marker blip icon (ID 0). All other icons will ignore this. + +**Parameters:** + +- `theBlip` (blip): The [[blip]] whose color you wish to get. + +**Returns:** + +Returns four integers in RGBA format, with a maximum value of 255 for each. The values are, in order, red, green, blue, and alpha. Alpha decides the transparancy where 255 is opaque and 0 is fully transparent. **false** is returned if the blip is invalid. +- int|false: r +- int: g +- int: b +- int: a + +**Examples:** + +Example 1: This example will find all the blips that exist and set them all to white if they aren't white already. +Example 2: This example will find all the blips that exist and set them all to white if they aren't white already. + +### getBlipIcon + +**Description:** This function returns the icon a blip currently has. See [Radar Blips](/reference/ID_Lists/Blips). + +**Parameters:** + +- `theBlip` (blip): The [[blip]] we're getting the icon number of. + +**Returns:** + +Returns an [[int]] indicating which [icon](/reference/ID_Lists/Blips) the [[blip]] has. **false** if blip element is invalid. +- int|false: icon + +**Examples:** + +Example 1: This example will find all the blips that exist and set them all to the default blip icon. +Example 2: This example will find all the blips that exist and set them all to the default blip icon. + +### getBlipOrdering + +**Description:** This function gets the Z ordering value of a [[blip]]. The Z ordering determines if a blip appears on top of or below other blips. Blips with a higher Z ordering value appear on top of blips with a lower value. The default value for all blips is 0. + +**Parameters:** + +- `theBlip` (blip): The [[blip]] to retrieve the Z ordering value of. + +**Returns:** + +Returns the Z ordering value of the [[blip]] if successful, **false** otherwise. +- int|false: z-ordering + +**Examples:** + + + +*...and 7 more functions in this category* + +--- + + +### Browser Functions + +*30 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 25 more functions in this category* + +--- + + +### Building Functions + +*1 functions in this category* + +### createBuilding + +**Description:** Creates a [[building]] element at a given position & interior with a certain rotation. + +**Parameters:** + +- `modelId` (int): A whole integer specifying the GTA:SA object model ID. See [Object IDs](/reference/ID_Lists/Objects) for a list of model IDs. +- `x` (float): A floating point number representing the X coordinate on the map. +- `y` (float): A floating point number representing the Y coordinate on the map. +- `z` (float): A floating point number representing the Z coordinate on the map. +- `rx` (float): A floating point number representing the rotation about the X axis in degrees. +- `ry` (float): A floating point number representing the rotation about the Y axis in degrees. +- `rz` (float): A floating point number representing the rotation about the Z axis in degrees. +- `interior` (int): The interior you want to set the building to. Valid values are 0 to 255. + +**Returns:** + +Returns the [[building]] element if the creation was successful, throws an error otherwise. +- building: building element + +**Examples:** + +Example 1: This example creates a building when the resource starts. +Example 2: This example creates a building when the resource starts. + +--- + + +### Camera Functions + +*20 functions in this category* + +### fadeCamera + +**Description:** This function will fade a player's camera to a color or back to normal over a specified time period. + +**Parameters:** + +- `thePlayer` (player): The [[player]] whose camera you wish to fade. +- `fadeIn` (bool): Should the camera be faded in or out? Pass **true** to fade the camera in, **false** to fade it out to a color. +- `timeToFade` (float): The number of seconds it should take to fade. +- `red` (int): The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in. +- `green` (int): The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in. +- `blue` (int): The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in. + +**Returns:** + +Returns **true** if the camera was faded successfully, **false** if invalid arguments were passed to the function. +- bool: result + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 15 more functions in this category* + +--- + + +### Clothes_and_body Functions + +*5 functions in this category* + +### Unknown + +**Description:** No description available + +### getBodyPartName + +**Description:** This function is used to get the name of a body part on a player. + +**Parameters:** + +- `bodyPartID` (int): An integer representing the body part ID you wish to retrieve the name of. + +**Returns:** + +This function returns a [[string]] containing the body part name if the ID is valid, **false** otherwise. +- string|false: body part name + +### getClothesByTypeIndex + +**Description:** This function is used to get the texture and model of clothes by the clothes type and index. (Scans through the list of clothes for the specific type). + +**Parameters:** + +- `clothesType` (int): An integer representing the clothes slot/type to scan through. +- `clothesIndex` (int): An integer representing the index (0 based) set of clothes in the list you wish to retrieve. Each type has a different number of valid indexes. + +**Returns:** + +This function returns 2 [[string]]s, a texture and model respectively, **false** if invalid arguments were passed to the function. +- string|false: texture +- string: model + +### getClothesTypeName + +**Description:** This function is used to get the name of a certain clothes type. + +**Parameters:** + +- `clothesType` (int): An integer determining the type of clothes you want to get the clothes of. + +**Returns:** + +This function returns a [[string]] (the name of the clothes type) if found, **false** otherwise. +- string|false: name + +### getTypeIndexFromClothes + +**Description:** This function is used to get the clothes type and index from the texture and model. (Scans through the list of clothes for the specific type). + +**Parameters:** + +- `clothesTexture` (string): A string determining the clothes texture that you wish to retrieve the type and index from. See the [clothes catalog](/reference/ID_Lists/CJ_Clothes). +- `clothesModel` (string): A string determining the corresponding clothes model that you wish to retrieve the type and index from. See the [clothes catalog](/reference/ID_Lists/CJ_Clothes). + +**Returns:** + +This function returns two [[int]]s, type and index respectively, **false** if invalid arguments were passed to the function. +- int|false: type +- int: index + +--- + + +### Colshape Functions + +*19 functions in this category* + +### addColPolygonPoint + +**Description:** This function is used to add a new point to an existing [colshape polygon](/reference/createColPolygon). + +**Parameters:** + +- `shape` (colshape): The colshape polygon you wish add a point to. +- `fX` (float): The X position of the new bound point. +- `fY` (float): The Y position of the new bound point. +- `index` (int): The index where the new point will be inserted in the polygon. The points are indexed in order, with 1 being the first bound point. Passing 0 will insert the point as the last one in the polygon. + +**Returns:** + +Returns **true** if the polygon was changed, **false** if invalid arguments were passed. +- bool: result + +### createColCircle + +**Description:** This function creates a collision circle. This is a shape that has a position and a radius and infinite height. Events will be triggered when a [[element]] enters or leaves it. + +**Parameters:** + +- `fX` (float): The collision circle's center point's X axis position. +- `fY` (float): The collision circle's center point's Y axis position. +- `radius` (float): The radius of the collision circle. Can not be smaller than 0.1. + +**Returns:** + +Returns a [[colshape]] element if successful, **false** if invalid arguments were passed to the function. +- colshape|false: col-circle + +### createColCuboid + +**Description:** This function creates a collision cuboid. This is a shape that has a position, width, depth and height. See [Wikipedia](http://en.wikipedia.org/wiki/Cuboid) for a definition of a cuboid. The XYZ of the col starts at the southwest bottom corner of the shape. + +**Parameters:** + +- `fX` (float): The X position of the collision cuboid's western side. +- `fY` (float): The Y position of the collision cuboid's southern side. +- `fZ` (float): The Z position of the collision cuboid's lowest side. +- `fWidth` (float): The collision cuboid's width. +- `fDepth` (float): The collision cuboid's depth. +- `fHeight` (float): The collision cuboid's height. + +**Returns:** + +Returns a [[colshape]] element if successful, **false** if invalid arguments were passed to the function. +- colshape|false: col-cuboid + +### createColPolygon + +**Description:** This function creates a collision polygon. See [Wikipedia](http://en.wikipedia.org/wiki/Polygon) for a definition of a polygon. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is **2D**. There should be at least 3 bound points set. + +**Parameters:** + +- `fCenterX` (float): The X position of the collision polygon's position - the position that will be returned from [[getElementPosition]]. +- `fCenterY` (float): The Y position of the collision polygon's position - the position that will be returned from [[getElementPosition]]. +- `fX1` (float): The 1st X position of the collision polygon's bound point +- `fY1` (float): The 1st Y position of the collision polygon's bound point +- `fX2` (float): The 2nd X position of the collision polygon's bound point +- `fY2` (float): The 2nd Y position of the collision polygon's bound point +- `fX3` (float): The 3rd X position of the collision polygon's bound point +- `fY3` (float): The 3rd Y position of the collision polygon's bound point +- `...` (): From the 3rd position you can have as many points as you require to create the colshape. + +**Returns:** + +Returns a [[colshape]] element if successful, **false** if invalid arguments were passed to the function. +- colshape|false: col-polygon + +### createColRectangle + +**Description:** This function creates a collision rectangle. This is a shape that has a position and a width and a depth and infinite height. See [Rectangle](http://en.wikipedia.org/wiki/Rectangle) for a definition of a rectangle. XY marks on the south west corner of the colshape. + +**Parameters:** + +- `fX` (float): The X position of the collision rectangle's west side. +- `fY` (float): The Y position of the collision rectangle's south side. +- `fWidth` (float): The collision rectangle's width. +- `fDepth` (float): The collision rectangle's depth. + +**Returns:** + +Returns a [[colshape]] element if successful, **false** if invalid arguments were passed to the function. +- colshape|false: col-rectangle + + +*...and 14 more functions in this category* + +--- + + +### Cursor Functions + +*6 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### isCursorShowing + +**Description:** This function determines the state of a [[player]]'s cursor. + +**Returns:** + +Returns **true** if the [[player]]'s cursor is visible, and **false** if it is not. + +- bool: result + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 1 more functions in this category* + +--- + + +### Database Functions + +*7 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 2 more functions in this category* + +--- + + +### Discord Functions + +*12 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + + +*...and 7 more functions in this category* + +--- + + +### Drawing Functions + +*43 functions in this category* + +### dxConvertPixels + +**Description:** This function converts [pixels](/wiki/Texture_pixels "Texture pixels") from one format to another. + +**Parameters:** + +- `pixels` (string): MISSING_PARAM_DESC +- `newFormat` (string): MISSING_PARAM_DESC +- `quality` (int): MISSING_PARAM_DESC + +**Returns:** + +Returns a copy of the pixels in the new format, or false if invalid arguments were passed to the function. +- string: value + +**Examples:** + +Example 1: The code opens an image, read its pixels, convert the pixels to PNG, and then save it. (You can usethisimage to test.) + +### dxCreateFont + +**Description:** This function creates a [DX font](/wiki/DX_font "DX font") element that can be used in [dxDrawText](/wiki/DxDrawText "DxDrawText"). Successful font creation is not guaranteed, and may fail due to hardware or memory limitations. + +**Parameters:** + +- `filepath` (string): the name of the file containing the font +- `size` (int): size of the font +- `bold` (bool): flag to indicate if the font should be bold +- `quality` (string): the font quality "default": not the actual default "draft" "proof": the default "nonantialiased" "antialiased" "cleartype" "cleartype_natural" + +**Returns:** + +Returns a DX font element if successful, false if invalid arguments were passed to the function, or there is insufficient resources available. +- element: value + +**Examples:** + + +### dxCreateRenderTarget + +**Description:** This function creates a render target element, which is a special type of [texture](/wiki/Texture "Texture") that can be drawn on with the dx functions. Successful render target creation is not guaranteed, and may fail due to hardware or memory limitations. + +**Parameters:** + +- `width` (int): MISSING_PARAM_DESC +- `height` (int): MISSING_PARAM_DESC +- `withAlpha` (bool): The render target will be created with an alpha channel. 'false' will turn images' alpha channels to black color + +**Returns:** + +Returns a texture element if successful, false if the system is unable to create a render target. +- element: value + +**Examples:** + + +### dxCreateScreenSource + +**Description:** This function creates a screen source, which is a special type of [texture](/wiki/Texture "Texture") that contains the screen as rendered by GTA + +**Parameters:** + +- `width` (int): MISSING_PARAM_DESC +- `height` (int): MISSING_PARAM_DESC + +**Returns:** + +Returns a texture element if successful, false if invalid arguments were passed to the function. +- element: value + +**Examples:** + + +### dxCreateShader + +**Description:** This function creates a [shader](/wiki/Shader "Shader") element that can be used in the dxDraw functions. Successful shader creation is not guaranteed unless the [Effect File](/wiki/Shader "Shader") contains a fallback technique which will work on every existing PC. + +**Parameters:** + +- `filepath / string raw_data` (string): MISSING_PARAM_DESC +- `priority` (float): If more than one shader is matched to a world texture, the shader with the highest priority will be used. If there is more than one shader with the same highest priority, the most recently created shader is used. +- `maxDistance` (float): If non-zero, the shader will be applied to textures nearer than maxDistance only. This can speed up rendering, but (to look good) may require the shader to fade out it's own effect as the texture reaches maxDistance. +- `layered` (bool): When set to true, the shader will be drawn in a separate render pass. Several layered shaders can be drawn on the same world texture. (To avoid Z fighting artifacts, you may have to add DepthBias=-0.0002; to the technique pass, but this might cause visual artifacts when applied on vehicles) +- `elementTypes` (string): A comma seperated list of element types to restrict this shader to. Valid element types are: world - Textures in the GTA world ped - Player and ped textures vehicle - Vehicles textures object - Objects textures other - Element textures which are not peds, vehicles or objects all - Everything +- `ped` (unknown): MISSING_PARAM_DESC +- `vehicle` (unknown): MISSING_PARAM_DESC +- `object` (unknown): MISSING_PARAM_DESC +- `other` (unknown): MISSING_PARAM_DESC +- `all"` (unknown): MISSING_PARAM_DESC + +**Returns:** + +element: A shader element if successful, false if invalid arguments were passed to the function. You should always check to see if this function has returned false. string: The name of the technique that will be used. +- element: value1 +- string: value2 + +**Examples:** + +Example 2: This example creates basic shader from raw data (without i/o) on resource start: + + +*...and 38 more functions in this category* + +--- + + +### Effects Functions + +*20 functions in this category* + +### createEffect + +**Description:** Creates an [effect](/wiki/Element/Effect "Element/Effect") on specified position. + +**Parameters:** + +- `name` (string): A string contains effect name . +- `x` (float): A floating point number representing the X coordinate on the map. +- `y` (float): A floating point number representing the Y coordinate on the map. +- `z` (float): A floating point number representing the Z coordinate on the map. +- `rX` (float): A floating point number representing the rotation about the X axis in degrees. +- `rY` (float): A floating point number representing the rotation about the Y axis in degrees. +- `rZ` (float): A floating point number representing the rotation about the Z axis in degrees. +- `drawDistance` (float): A floating point number between 1 and 8191 which represents the draw distance of the effect, or 0 to use the default draw distance. +- `soundEnable` (bool): MISSING_PARAM_DESC + +**Returns:** + +Returns the effect element if creation was successful, false otherwise. +- effect: value + +**Examples:** + +Example 1: This example allows you to create effect by using 'B' key (use mouse scroll up/down to switch effect). + +### fxAddBlood + +**Description:** Creates a blood splatter particle effect. + +**Parameters:** + +- `posX` (float): MISSING_PARAM_DESC +- `posY` (float): MISSING_PARAM_DESC +- `posZ` (float): MISSING_PARAM_DESC +- `dirX` (float): MISSING_PARAM_DESC +- `dirY` (float): MISSING_PARAM_DESC +- `dirZ` (float): MISSING_PARAM_DESC +- `count` (int): the number of flying droplets to create. +- `brightness` (float): the brightness. Ranges from 0 (almost black) to 1 (normal color). + +**Returns:** + +- bool: value + +**Examples:** + +Example 1: This example creates blood effects when a player gets shot. + +### fxAddBulletImpact + +**Description:** Creates a bullet impact particle effect, consisting of a small smoke cloud and a number of sparks. + +**Parameters:** + +- `posX` (float): MISSING_PARAM_DESC +- `posY` (float): MISSING_PARAM_DESC +- `posZ` (float): MISSING_PARAM_DESC +- `dirX` (float): MISSING_PARAM_DESC +- `dirY` (float): MISSING_PARAM_DESC +- `dirZ` (float): MISSING_PARAM_DESC +- `smokeSize` (int): the size of the smoke cloud. +- `sparkCount` (int): the number of sparks to create. +- `smokeIntensity` (float): the amount/transparency of smoke, ranges from 0 to 1. + +**Returns:** + +Returns a true if the operation was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will create a Bullet Impact Effect on the position of the bullet impact. + +### fxAddBulletSplash + +**Description:** This function creates a bullet splash particle effect, normally created when shooting into water. + +**Parameters:** + +- `posX` (float): A float representing the x position of the splash +- `posY` (float): A float representing the y position of the splash +- `posZ` (float): A float representing the z position of the splash + +**Returns:** + +Returns a true if the operation was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will add a Bullet Splash Effect next to your player when typing/bsplashin the Chatbox. + +### fxAddDebris + +**Description:** Creates a debris particle effect (e.g. bits that fly off a car when ramming a wall). + +**Parameters:** + +- `posX` (float): MISSING_PARAM_DESC +- `posY` (float): MISSING_PARAM_DESC +- `posZ` (float): MISSING_PARAM_DESC +- `colorR` (int): MISSING_PARAM_DESC +- `colorG` (int): MISSING_PARAM_DESC +- `colorB` (int): MISSING_PARAM_DESC +- `colorA` (int): MISSING_PARAM_DESC +- `scale` (float): the size of the chunks. +- `count` (int): the number of chunks to create. + +**Returns:** + +Returns a true if the operation was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will create a Debris Effect next to you when typing/debrisin the Chatbox. + + +*...and 15 more functions in this category* + +--- + + +### Element Functions + +*95 functions in this category* + +### addElementDataSubscriber + +**Description:** This function subscribes a [player](/wiki/Player "Player") to specific [element data](/wiki/Element_data "Element data"). +This function is used together with [setElementData](/wiki/SetElementData "SetElementData") in *"subscribe"* mode. + +**Parameters:** + +- `theElement` (element): The element you wish to subscribe the player to. +- `key` (string): The key you wish to subscribe the player to. +- `thePlayer` (player): The player you wish to subscribe. + +**Returns:** + +Returns true if the player was subscribed, false otherwise. +- bool: value + +**Examples:** + + +### attachElements + +**Description:** This function attaches one element to another, so that the first one follows the second whenever it moves. + +**Parameters:** + +- `theElement` (element): The element to be attached. +- `theAttachToElement` (element): The element to attach the first to. +- `xPosOffset` (float): The x offset, if you want the elements to be a certain distance from one another (default 0). +- `yPosOffset` (float): The y offset (default 0). +- `zPosOffset` (float): The z offset (default 0). +- `xRotOffset` (float): The x rotation offset (default 0). +- `yRotOffset` (float): The y rotation offset (default 0). +- `zRotOffset` (float): The z rotation offset (default 0). + +**Returns:** + +Returns true if the attaching process was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: Example 1:This example attaches a marker to the player who steals the Mr. Whoopee: +Example 2: Example 3:This function adds a tank on top of a player (for extra defense), clientside. This means it will be invisible to other players. + +### clearElementVisibleTo + +**Description:** This function clears any settings added by [setElementVisibleTo](/wiki/SetElementVisibleTo "SetElementVisibleTo") and restores an [element](/wiki/Element "Element") to its default [visibility](/wiki/Visibility "Visibility"). + +**Parameters:** + +- `theElement` (element): The element in which you wish to restore to its default visibility + +**Returns:** + +Returns true if the operation was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example clears any visibility settings after a player dies, so everyone can see his blip for a short period + +### cloneElement + +**Description:** This function clones (creates an exact copy of) an already existing element. The root node, and player elements, cannot be cloned. If a player element is a child of an element that is cloned, it will be skipped, along with the elements that exist as a child to the player element. + +**Parameters:** + +- `theElement` (element): The element that you wish to clone. +- `xPos` (float): A floating point number representing the X coordinate on the map. +- `yPos` (float): A floating point number representing the Y coordinate on the map. +- `zPos` (float): A floating point number representing the Z coordinate on the map. +- `cloneChildren` (bool): A boolean value representing whether or not the element's children will be cloned. + +**Returns:** + +Returns the handle of the new cloned element of the parent, false if invalid arguments were passed. +- element: value + +**Examples:** + +Example 1: This example clones the vehicle a player is in. This allows carrying over of the current state of the vehicle, including mods, for example. + +### createElement + +**Description:** This function is used to create a new dummy element in the [element tree](/wiki/Element_tree "Element tree") which do not necessarily represent an entity within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base. + +**Parameters:** + +- `elementType` (string): The type of element being created. +- `elementID` (string): The ID of the element being created. + +**Returns:** + +Returns the element if it was successfully created. Returns false if the arguments are wrong. +- element: value + +**Examples:** + +Example 1: This example creates a "flag" element, named "blue", which will be at the resource's dynamic map. +Example 2: Except for it being placed in a different map root, that line will have the same effect as having this in a .map file: + + +*...and 90 more functions in this category* + +--- + + +### Engine Functions + +*74 functions in this category* + +### engineAddClothingModel + +**Description:** This function adds new CJ clothing model. + +**Parameters:** + +- `theModel` (dff): The model that will be added. +- `fileName` (string): Name of the file containing the TXD/DFF extension. + +**Returns:** + +Returns true if the model was added, and false otherwise. +- bool: value + +### engineAddClothingTXD + +**Description:** This function adds new CJ clothing texture. + +**Parameters:** + +- `theTexture` (txd): The texture that will be added. +- `fileName` (string): Name of the file containing the TXD extension. + +**Returns:** + +Returns true if the texture was added, and false otherwise. +- bool: value + +### engineAddImage + +**Description:** This function adds an IMG file container to GTA streamer. After this GTA will asynchronously load models from IMG. **Only two additional archives can be enabled once** + +**Parameters:** + +- `imgArchive` (img): The IMG file you want to add to GTA world. + +**Returns:** + +Returns true if the IMG element was successfully added, false otherwise. +- boolean: value + +### engineApplyShaderToWorldTexture + +**Description:** This function applies a [shader](/wiki/Shader "Shader") to one or more world textures. + +**Parameters:** + +- `shader` (element): The shader which is to be applied +- `textureName` (string): The name of the world texture to apply the shader to. Wildcard matching e.g. "ro?ds*" can be used to apply to more than one texture at a time. +- `targetElement` (element): The element to restrict applying the shader to. If this is not set the shader will be applied to everything using the texture name. Valid element types for targetElement are vehicles , objects and peds . +- `appendLayers` (bool): allows two or more layered shaders to be applied in the same texture. You may want to modify the DepthBias in the technique pass to avoid Z-fighting artifacts when using this. + +**Returns:** + +Returns true if the shader was successfully applied, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will replace the texture of a group of common explosions (grenades, rockets, etc) with a custom explosion effect +Example 2: This example will apply a shader to the "des_logwall" world texture (which is used by the house near the 'play' gamemode spawn point) + +### engineFreeModel + +**Description:** This function is used to un\-assign the specified model ID from the [engineRequestModel](/wiki/EngineRequestModel "EngineRequestModel") assignment. + +**Parameters:** + +- `modelID` (int): the model ID you want to have un-assigned. + +**Returns:** + +Returns true if the model was successfully freed, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example creates a ped and then gives you the opportunity to change its model. If the resource stops, then the IDs allocated will be deallocated. Use/capfor creating the ped and/sapto skin the ped. You will need some skins added to a folder and to the meta.xml for/sapto work. + + +*...and 69 more functions in this category* + +--- + + +### Event Functions + +*15 functions in this category* + +### addEvent + +**Description:** This function allows you to register a custom [event](/wiki/Event "Event"). Custom events function exactly like the built\-in events. See [event system](/wiki/Event_system "Event system") for more information on the event system. + +**Parameters:** + +- `eventName` (string): The name of the event you wish to create. +- `allowRemoteTrigger` (bool): A boolean specifying whether this event can be called remotely using triggerClientEvent / triggerServerEvent or not. + +**Returns:** + +Returns true if the event was added successfully, false if the event was already added. +- bool: value + +**Examples:** + +Example 1: This example will define a new event calledonSpecialEvent. +Example 2: You can then trigger this event later on using: + +### addEventHandler + +**Description:** This function will add an [event](/wiki/Event "Event") handler. An event handler is a function that will be called when the event it's attached to is triggered. See [event system](/wiki/Event_system "Event system") for more information on how the event system works. + +**Parameters:** + +- `eventName` (string): The name of the event you want to attach the handler function to. Note: The maximum allowed length is 100 ASCII characters (that is, English letters and numerals) +- `attachedTo` (element): The element you wish to attach the handler to. The handler will only be called when the event it is attached to is triggered for this element, or one of its children. Often, this can be the root element (meaning the handler will be called when the event is triggered for any element). +- `handlerFunction` (function): The handler function you wish to call when the event is triggered. This function will be passed all of the event's parameters as arguments, but it isn't required that it takes all of them. +- `propagate` (bool): A boolean representing whether the handler will be triggered if the event was propagated down or up the element tree (starting from the source), and not triggered directly on attachedTo (that is, handlers attached with this argument set to false will only be triggered if source == this ). In GUI events you will probably want to set this to false . +- `priority` (string): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the event handler was attached successfully. Returns false if the specified event could not be found or any parameters were invalid. +- bool: value + +**Examples:** + +Example 1: This serverside example sends a message to everyone in the server when a player spawns. + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### getCancelReason + +**Description:** Gets the reason for cancelling an event. + +**Returns:** + +Returns the reason that was given with cancelEvent +- string: value + +**Examples:** + +Example 1: This example cancels when a hunterPlayer tries to enter a vehicle and outputs to the world what the player tried to do. + + +*...and 10 more functions in this category* + +--- + + +### Explosion Functions + +*1 functions in this category* + +### Unknown + +**Description:** No description available + +--- + + +### File Functions + +*17 functions in this category* + +### fileClose + +**Description:** Closes a file handle obtained by [[fileCreate]] or [[fileOpen]]. + +**Parameters:** + +- `theFile` (file): The file handle to close. + +**Returns:** + +Returns **true** if successful, **false** otherwise. +- bool: result + +**Examples:** + +Example 1: This example creates a text file and writes a string to it. +Example 2: This example creates a text file and writes a string to it. + +### fileCopy + +**Description:** This function copies a file. + +**Parameters:** + +- `filePath` (string): The path of the file you want to copy. +- `copyToFilePath` (string): Where to copy the specified file to. +- `overwrite` (bool): If set to true it will overwrite a file that already exists at `copyToFilePath`. + +**Returns:** + +Return **true** if the file was copied, else **false** if the `filePath` doesn't exist. +- bool: result + +### fileCreate + +**Description:** Creates a new file in a directory of a resource. If there already exists a file with the specified name, it is overwritten with an empty file. + +**Parameters:** + +- `filePath` (string): The path of the file you want to copy. + +**Returns:** + +If successful, returns a [[file]] handle which can be used with other file functions ([[fileWrite]], [[fileClose]] etc.). Returns **false** if an error occured. +- bool: result + +**Examples:** + +Example 1: This example creates a text file in the current resource and writes a string to it. +Example 2: This example creates a text file in the current resource and writes a string to it. + +### fileDelete + +**Description:** Deletes the specified file. + +**Parameters:** + +- `filePath` (string): The [Filepath](/reference/Filepath) of the file to delete in the following format: `:resourceName/path`. `resourceName` is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. +For example, if you want to delete a file name "myFile.txt" in the resource 'fileres', it can be deleted from another resource this way: `fileDelete(":fileres/myFile.txt")`. +If the file is in the current resource, only the file path is necessary, e.g. `fileDelete("myFile.txt")`. + + +**Returns:** + +Returns **true** if successful, **false** otherwise (for example if there exists no file with the given name, or it does exist but is in use). +- bool: result + +**Examples:** + +Example 1: This example will show us how to create a file "text.txt" spell it "This is a test file!", Close the file and delete it. +Example 2: This example will show us how to create a file "text.txt" spell it "This is a test file!", Close the file and delete it. + +### fileExists + +**Description:** This functions checks whether a specified file exists inside a resource. + +**Parameters:** + +- `filePath` (string): The [Filepath](/reference/Filepath) of the file, whose existence is going to be checked, in the following format: `:resourceName/path`. `resourceName` is the name of the resource the file is checked to be in, and 'path' is the path from the root directory of the resource to the file. +For example, if you want to check whether a file named 'myfile.txt' exists in the resource 'mapcreator', it can be done from another resource this way: `fileExists(":mapcreator/myfile.txt")`. +If the file, whose existence is going to be checked, is in the current resource, only the file path is necessary, e.g. `fileExists("myfile.txt")`. Note that you must use forward slashes '/' for the folders, backslashes '\' will return false. + + +**Returns:** + +Returns **true** if the file exists, **false** otherwise. +- bool: result + +**Examples:** + +Example 1: This example checks if a file exists in a resource directory. +Example 2: This example checks if a file exists in a resource directory. + + +*...and 12 more functions in this category* + +--- + + +### Fire Functions + +*2 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +--- + + +### GUI Functions + +*139 functions in this category* + +### getChatboxCharacterLimit + +**Description:** Gets the current maximum amount of characters that can be input via chatbox + +**Returns:** + +Returns a number between 0-255, representing the chatbox input character limit +- int: value + +**Examples:** + +Example 1: This example shows how you can check your current chatbox character limit via command + +### getChatboxLayout + +**Description:** Returns information about how the chatbox looks. + +**Parameters:** + +- `CVar` (string): the name of the property you want returned. Can be the following values: chat_font - Returns the chatbox font chat_lines - Returns how many lines the chatbox has chat_color - Returns the background color of the chatbox chat_text_color - Returns the chatbox text color chat_input_color - Returns the background color of the chatbox input chat_input_prefix_color - Returns the color of the input prefix text chat_input_text_color - Returns the color of the text in the chatbox input chat_scale - Returns the scale of the text in the chatbox chat_position_offset_x - Returns the x position offset setting chat_position_offset_y - Returns the y position offset setting chat_position_horizontal - Returns the horizontal alignment setting chat_position_vertical - Returns the vertical alignment setting chat_text_alignment - Returns the text alignment setting chat_width - Returns the scale of the background width chat_css_style_text - Returns whether text fades out over time chat_css_style_background - Returns whether the background fades out over time chat_line_life - Returns how long it takes for text to start fading out chat_line_fade_out - Returns how long takes for text to fade out chat_use_cegui - Returns whether CEGUI is used to render the chatbox text_scale - Returns text scale chat_text_outline - Returns whether text black/white outline is used + +**Returns:** + +This code makes the chatbox empty when you type /clear +- bool|int|table: value + +**Examples:** + +Example 1: This code makes the chatbox empty when you type /clear +Example 2: This code makes the chatbox empty when you type /clear, but with a cleaner code + +### guiBlur + +**Description:** This function defocuses a focused GUI element. Used primarily for edit fields and memos. + +**Parameters:** + +- `guiElement` (element): the GUI element that you want to defocus + +**Returns:** + +Returns true if the function was successful, false otherwise. +- bool: value + +**Examples:** + + +### guiBringToFront + +**Description:** This function brings a GUI element on top of others. + +**Parameters:** + +- `guiElement` (element): the GUI element that you want to move to the front. + +**Returns:** + +Returns true if the function was successful, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example creates a gui window and brings it on top. + +### guiCheckBoxGetSelected + +**Description:** This function gets a checkbox's selection state. + +**Parameters:** + +- `theCheckbox` (element): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the checkbox is selected, false if it is not. +- bool: value + +**Examples:** + +Example 1: This example makes a different beep based on the state when any checkbox has been clicked. + + +*...and 134 more functions in this category* + +--- + + +### HTTP Functions + +*6 functions in this category* + +### httpClear + +**Description:** This function removes all text from the current HTML output. + +**Returns:** + +Returns true if the output buffer was cleared successfully, false otherwise. +- bool: value + +**Examples:** + +Example 1: This sample resource page adds a message to be outputted saying there are players in the server, but clears output if the server is empty so a blank page is displayed instead. + +### httpRequestLogin + +**Description:** This function makes the user's browser show a 'basic authentication' login box. The result of the login is handled automatically by the server. If the user has not logged in satisfactorily, you should just call the httpRequestLogin function again. It is the script's responsibility to judge when the user is logged in satisfactorily \- you can use the *user* variable can be used to check if the user has logged in with an account you are happy with. If the logged in user doesn't meet whatever criteria you have, you can just call httpRequestLogin again and they will be re\-promoted for their password. + +**Returns:** + +Returns true if the relevant headers and return codes have been set, false otherwise. Essentially, always returns true . +- bool: value + +**Examples:** + +Example 1: This example shows how you can make a page that only registered users can see. + +### httpSetResponseCode + +**Description:** This function sets the HTTP status code that will be sent for the current HTML page. + +**Parameters:** + +- `code` (int): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the code was set successfully, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example displays a 'Page not found' error message and the response code 404. The location of thehttpSetResponseCodecall is unimportant - it can be placed anywhere in the document. + +### httpSetResponseCookie + +**Description:** This function sets the value for the specified HTTP cookie of the current HTML page. + +**Parameters:** + +- `cookieName` (string): MISSING_PARAM_DESC +- `cookieValue` (string): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the cookie value was set successfully, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example is going to get the current users account name and save their name to a cookie. + +### httpSetResponseHeader + +**Description:** This function sets the value for the specified HTTP response header of the current HTML page. + +**Parameters:** + +- `headerName` (string): MISSING_PARAM_DESC +- `headerValue` (string): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the header value was set successfully, false otherwise. +- bool: value + +**Examples:** + +Example 1: Using httpSetResponseHeader to set the content type. (Example fromhttpWrite) + + +*...and 1 more functions in this category* + +--- + + +### Input Functions + +*19 functions in this category* + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### Unknown + +**Description:** No description available + +### getAnalogControlState + +**Description:** This retrieves the analog control state of a control. This is useful for detecting sensitive controls, such as those used on a joypad. + +**Parameters:** + +- `control` (string): The control that you want to get the state of. See control names for a list of possible controls. +- `rawValue` (bool): A bool indicating if it should return the raw player input value. + +**Returns:** + +Returns a float between 0 and 1 indicating the amount the control is pressed. +- float: value + +**Examples:** + +Example 1: This creates an/forwardscommand, which toggles yourforwardscontrol state between 0 and 1. + +### getBoundKeys + +**Description:** Returns a list of key names that are bound to the specified game [control](/wiki/Control_names "Control names") or console command. + +**Parameters:** + +- `command/control` (string): the name of a game control or a console command. See the control names page for valid controls. + +**Returns:** + +If one or more keys are bound to the specified control or console command, a table is returned indexed by the names of the keys and containing key states as values. If no keys are bound or an invalid name was passed, returns false . +- table: value + +**Examples:** + +Example 1: This code adds a command handler with which you can check out the keybinds for any game control. As an example, typing "/keys forwards" would list all the keys which you can press to make the player walk forward. + + +*...and 14 more functions in this category* + +--- + + +### Light Functions + +*8 functions in this category* + +### createLight + +**Description:** This function creates a 3D [light](/wiki/Element/Light "Element/Light") in the world. + +**Parameters:** + +- `lightType` (int): An integer representing the type of light to create. 0 : Point light, which illuminates surroundings evenly across the light radius. 1 : Spot light, which illuminates the direction of the light defined by dirX , dirY and dirZ . 2 : Dark light, which darkens its surrounding elements to full black. +- `posX` (float): A floating point number representing the X coordinate on the map. +- `posY` (float): A floating point number representing the Y coordinate on the map. +- `posZ` (float): A floating point number representing the Z coordinate on the map. +- `radius` (float): A floating point number representing the radius of the light. +- `r` (int): An integer number representing the amount of red to use in the colouring of the light (0 - 255). +- `g` (int): An integer number representing the amount of green to use in the colouring of the light (0 - 255). +- `b` (int): An integer number representing the amount of blue to use in the colouring of the light (0 - 255). +- `dirX` (float): A floating point number representing the light direction's X coordinate on the map. +- `dirY` (float): A floating point number representing the light direction's Y coordinate on the map. +- `dirZ` (float): A floating point number representing the light direction's Z coordinate on the map. + +**Returns:** + +Returns the light element if creation was successful, false otherwise. +- light: value + +**Examples:** + +Example 1: This example will make every player to look completely black without using shaders. It will also dark vehicles he uses too. + +### getLightColor + +**Description:** This function returns the color for a [light](/wiki/Element/Light "Element/Light") element. + +**Parameters:** + +- `theLight` (light): The light that you wish to retrieve the color of. + +**Returns:** + +Returns three ints corresponding to the amount of red, green and blue (respectively) of the light, false if invalid arguments were passed. +- int: value1 +- int: value2 +- int: value3 + +**Examples:** + + +### getLightDirection + +**Description:** This function returns the direction for a [light](/wiki/Element/Light "Element/Light") element. + +**Parameters:** + +- `theLight` (light): The light that you wish to retrieve the direction of. + +**Returns:** + +Returns three ints corresponding to the x, y and z coordinates (respectively) of the light direction, false if invalid arguments were passed. +- float: x +- float: y +- float: z + +**Examples:** + + +### getLightRadius + +**Description:** This function returns the radius for a [light](/wiki/Element/Light "Element/Light") element. + +**Parameters:** + +- `theLight` (light): The light that you wish to retrieve the radius of. + +**Returns:** + +Returns a float containing the radius of the specified light, false if invalid arguments were passed. +- float: value + +**Examples:** + + +### getLightType + +**Description:** This function returns the type for a [light](/wiki/Element/Light "Element/Light") element. + +**Parameters:** + +- `theLight` (light): The light that you wish to retrieve the type of. + +**Returns:** + +Returns an int containing the type of the specified light, false if invalid arguments were passed. +- int: value + +**Examples:** + + + +*...and 3 more functions in this category* + +--- + + +### Map Functions + +*3 functions in this category* + +### loadMapData + +**Description:** This function is intended to load data from a loaded XML file into the element tree. This could be used for loading an external map, or part of another map. + +**Parameters:** + +- `node` (xmlnode): The node that you wish to load into the element tree . +- `parent` (element): The node you wish to be the parent of the new map data. + +**Returns:** + +Returns an element object that corresponds to the root of the new data added, i.e. an element that represents the node xmlnode passed to the function. Returns false if the arguments are invalid. +- element: value + +**Examples:** + +Example 1: Example 1:This example is a function that you could use to load an arbitarymap fileinto theelement tree. +Example 2: Example 2:This example will destroy the loaded map data after 30 seconds. + +### resetMapInfo + +**Description:** This function is used to reset the state of a player. It is intended to restore a player to his default state as if he had just joined the server, without any scripts affecting him. + +**Parameters:** + +- `thePlayer` (player): The specific player you wish to restore the state of. Not specifying this will result in all players map info being reset. + +**Returns:** + +Returns true if the map info was reset successfully, otherwise false . +- bool: value + +**Examples:** + +Example 1: This will reset all map info when the resource is stopped. + +### saveMapData + +**Description:** This converts a set of elements in the element tree into XML. This is a format that can then be loaded as a map file. Each element represents a single XML node. + +**Parameters:** + +- `node` (xmlnode): An existing node that should contain the contents of baseElement +- `baseElement` (element): The first element to output to the XML tree. This element and all its children (and their children, etc) will be output. +- `childrenOnly` (bool): Defines if you want to only save children of the specified element. + +**Returns:** + +Saving your resource's data to an map file (untested) +- bool: value + +**Examples:** + +Example 1: Saving your resource's data to anmap file(untested) + +--- + + +### Marker Functions + +*16 functions in this category* + +### Unknown + +**Description:** No description available + +### getMarkerColor + +**Description:** This function returns the color and transparency for a marker element. + +**Parameters:** + +- `theMarker` (marker): The marker that you wish to retrieve the color of. + +**Returns:** + +Returns four ints corresponding to the amount of red , green , blue and alpha (respectively) of the marker, false if invalid arguments were passed. +- int: value1 +- int: value2 +- int: value3 +- int: value4 + +**Examples:** + +Example 1: This example script fully heals players who hit a white marker, and kills players who hit a red one. + +### getMarkerCount + +**Description:** Returns the number of markers that currently exist in the world. + +**Returns:** + +Returns the number of markers that currently exist. +- int: value + +**Examples:** + +Example 1: This example outputs the amount of markers to the player. + +### getMarkerIcon + +**Description:** This function returns the icon name for a marker. + +**Parameters:** + +- `theMarker` (marker): A marker element referencing the specified marker. + +**Returns:** + +Returns false if the marker passed is invalid or a string containing one of the following: +- string: value + +**Examples:** + + +### getMarkerSize + +**Description:** This function returns a [float](/wiki/Float "Float") containing the size of the specified marker. + +**Parameters:** + +- `myMarker` (marker): The marker that you wish to retrieve the size of. + +**Returns:** + +Returns a float containing the size of the specified marker. +- float: value + +**Examples:** + +Example 1: This example creates a marker and outputs the size to everyone. + + +*...and 11 more functions in this category* + +--- + + +### Module Functions + +*2 functions in this category* + +### getLoadedModules + +**Description:** This function returns all the currently loaded [modules](/wiki/Modules "Modules") of the server. + +**Returns:** + +Returns a table of all the currently loaded modules . If no modules are loaded, the table will be empty. +- table: value + +**Examples:** + +Example 1: Adds a command that lists all loaded modules in the server log. + +### getModuleInfo + +**Description:** This function returns information about the specified [module](/wiki/Modules "Modules"). + +**Parameters:** + +- `moduleName` (string): A string containing the module you wish to get information of e.g. "hashing.dll" + +**Returns:** + +Returns a table containing information about module. These keys are present in the table: +- table: value + +**Examples:** + +Example 1: This example adds a commandcheckmoduleswith which you can view information about currently loaded modules. + +--- + + +### Object Functions + +*16 functions in this category* + +### breakObject + +**Description:** This function breaks a specific object. + +**Parameters:** + +- `theObject` (object): an object element + +**Returns:** + +This example checks if the object created is breakable and if it is then breaks it. +- bool: value + +**Examples:** + +Example 1: This example checks if the object created is breakable and if it is then breaks it. + +### createObject + +**Description:** Creates an [object](/wiki/Object "Object") [element](/wiki/Element "Element") at a given position and rotation. + +**Parameters:** + +- `modelId` (int): A whole integer specifying the GTA:SA object model ID. See Object IDs for a list of model IDs. +- `x` (float): A floating point number representing the X coordinate on the map. +- `y` (float): A floating point number representing the Y coordinate on the map. +- `z` (float): A floating point number representing the Z coordinate on the map. +- `rx` (float): A floating point number representing the rotation about the X axis in degrees. +- `ry` (float): A floating point number representing the rotation about the Y axis in degrees. +- `rz` (float): A floating point number representing the rotation about the Z axis in degrees. +- `isLowLOD` (bool): MISSING_PARAM_DESC + +**Returns:** + +- object: value + +**Examples:** + +Example 1: This example shows you how to automatically create an object or building element according to certain parameters. +Example 2: This example creates an object when the resource starts: + +### getObjectMass + +**Description:** This function returns the mass of a specified object. + +**Parameters:** + +- `theObject` (object): the object whose mass you want to get. + +**Returns:** + +This script basically creates an object then get's the mass and set's its mass 300 more than it's original mass, then tell the client the old and new mass of the object. +- float: value + +**Examples:** + +Example 1: This script basically creates an object then get's the mass and set's its mass 300 more than it's original mass, then tell the client the old and new mass of the object. + +### getObjectProperty + +**Description:** This function gets a property of the specified [object](/wiki/Object "Object"). + +**Parameters:** + +- `theObject` (object): the object you wish to get a property of. +- `property` (string): the property you want to get the value of: + +**Returns:** + +On success: table for all , 3 floats for center_of_mass or float for other properties +- mixed: value + +**Examples:** + + +### getObjectScale + +**Description:** This function returns the visible size of an object. + +**Parameters:** + +- `theObject` (object): the object you wish to return the scale of. + +**Returns:** + +- float: x +- float: y +- float: z + +**Examples:** + +Example 1: This example adds a command namedgetscalewhich creates an object and prints out the scale of it. + + +*...and 11 more functions in this category* + +--- + + +### Output Functions + +*9 functions in this category* + +### Unknown + +**Description:** No description available + +### clearDebugBox + +**Description:** This function clears the debug box. + +**Returns:** + +Always returns true . +- bool: value + +**Examples:** + +Example 1: This example clears the debug window when any new debug message is displayed: + +### isChatInputBlocked + +**Description:** This function checks if the player's chat input is blocked. + +**Returns:** + +Returns true if the chat input is blocked, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example shows how to block and unblock the chat input: + +### isChatVisible + +**Description:** This function checks if player's chat is visible. + +**Returns:** + +Returns true if the chat is visible, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example does the same thing asshowchatcommand does. + +### Unknown + +**Description:** No description available + + +*...and 4 more functions in this category* + +--- + + +### Path Functions + +*3 functions in this category* + +### pathIsDirectory + +**Description:** Checks if a specified path points to a directory. + +**Parameters:** + +- `path` (string): A string containing a path you want to check against + +**Returns:** + +Returns true if the path points to a directory, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example lists entire structure of a folder + +### pathIsFile + +**Description:** Checks if a specified path points to a file. + +**Parameters:** + +- `path` (string): A string containing a path you want to check against + +**Returns:** + +Returns true if the path points to a file, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example lists all files in a directory + +### pathListDir + +**Description:** Reads a specified directory and returns all entries inside of it. These entries can be file or folder names. + +**Parameters:** + +- `path` (string): A string containing a path you want to get entries from + +**Returns:** + +Returns table with all entries in a specified directory. +- table: value + +**Examples:** + +Example 1: This example loads all models from a certain directory + +--- + + +### Ped Functions + +*79 functions in this category* + +### IsPedFootBloodEnabled + +**Description:** This function checks if player feets are bleeding. + +**Parameters:** + +- `thePlayer` (element): The player to give bloody foot prints to. + +**Returns:** + +Returns true if feets are bleeding, false otherwise +- bool: value + +**Examples:** + + +### addPedClothes + +**Description:** This function is used to set the current clothes on a [ped](/wiki/Ped "Ped"). + +**Parameters:** + +- `thePed` (ped): The ped whose clothes you want to change. +- `clothesTexture` (string): A string determining the clothes texture that will be added. See the clothes catalog . +- `clothesModel` (string): A string determining the clothes model that will be added. See the clothes catalog . +- `clothesType` (int): A integer representing the clothes slot/type the clothes should be added to. See the clothes catalog . + +**Returns:** + +This function returns true if the clothes were successfully added to the ped, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example adds a 'moto' helmet to a player when he gets on a nrg bike, and removes it when he gets off. + +### canPedBeKnockedOffBike + +**Description:** This function checks if the given ped can fall off bikes. + +**Parameters:** + +- `thePed` (ped): the ped you want to check. + +**Returns:** + +Returns true if the ped can be knocked off bikes, false if he cannot or an invalid element was passed. +- bool: value + +**Examples:** + +Example 1: This example adds a console command with which the local player can toggle whether he can fall off bikes. + +### Unknown + +**Description:** No description available + +### getPedAmmoInClip + +**Description:** This function returns an integer that contains the ammo in a specified [ped](/wiki/Ped "Ped")'s weapon. See [Weapon Info](/wiki/Weapon "Weapon") + +**Parameters:** + +- `thePed` (ped): The ped whose ammo you want to check. +- `weaponSlot` (int): an integer representing the weapon slot (set to the ped's currently selected slot if not specified). + +**Returns:** + +Returns an int containing the amount of ammo in the specified ped's currently selected or specified clip, or 0 if the ped specified is invalid. +- int: value + +**Examples:** + +Example 1: This example outputs the amount of ammo the specified player has in his current slot. For example: 'ammo someguy'. + + +*...and 74 more functions in this category* + +--- + + +### Pickup Functions + +*10 functions in this category* + +### createPickup + +**Description:** This function creates a pickup element, which is placed in the GTA world and can be picked up to retrieve a health, armour or a weapon. + +**Parameters:** + +- `x` (float): A floating point number representing the X coordinate on the map. +- `y` (float): A floating point number representing the Y coordinate on the map. +- `z` (float): A floating point number representing the Z coordinate on the map. +- `theType` (int): This is an integer representing the type of pickup, representing the following types: 0 : Health Pickup 1 : Armour Pickup 2 : Weapon Pickup 3 : Custom Pickup +- `amount/weapon/model` (int): MISSING_PARAM_DESC +- `respawnTime` (int): How long before the pickup respawns in milliseconds ( This parameter is ignored on the client! ) +- `ammo` (int): An integer representing the amount of ammo a pickup contains. This is only valid when the pickup type is a weapon pickup. + +**Returns:** + +Returns pickup element if the pickup was created succesfully, otherwise returns false . +- pickup: value + +**Examples:** + +Example 1: This example creates a pickup after a player dies so that he drops his weapon. +Example 2: This example creates a custom pickup(money) after a player dies and sets it's value. + +### getPickupAmmo + +**Description:** This function retrieves the amount of ammo in a weapon pickup. + +**Parameters:** + +- `thePickup` (pickup): The pickup in which you wish to retrieve the ammo of + +**Returns:** + +Returns an integer of the amount of ammo in the pickup, false if the pickup element is invalid, 0 if it's no weapon pickup. +- int: value + +**Examples:** + + +### getPickupAmount + +**Description:** This function retrieves the amount of health or armor given from a pickup. + +**Parameters:** + +- `thePickup` (pickup): The pickup you wish to retrieve the amount from. + +**Returns:** + +Returns an integer of the amount the pickup is set to, false if it's invalid, 0 if it's no health or amor pickup. +- int: value + +**Examples:** + + +### getPickupRespawnInterval + +**Description:** Returns the time it takes before a pickup respawns after a player picked it up. The time is specified in milliseconds. + +**Parameters:** + +- `thePickup` (pickup): the pickup you want the respawn time of + +**Returns:** + +Returns the respawn time of the pickup if successful, false in case of failure. +- int: value + +**Examples:** + +Example 1: This example outputs to the player that picked up the pickup, that it's not going to spawn again for another ... secs. + +### getPickupType + +**Description:** This function retrieves the type of a pickup, either a health, armour or weapon pickup. + +**Parameters:** + +- `thePickup` (pickup): The pickup you wish to retrieve the type of. + +**Returns:** + +Returns false if the pickup is invalid, or an integer of the type of the pickup, which include: +- int: value + +**Examples:** + + + +*...and 5 more functions in this category* + +--- + + +### Player Functions + +*58 functions in this category* + +### countPlayersInTeam + +**Description:** This function is for returning the number of players in the specified team. + +**Parameters:** + +- `theTeam` (team): The team you wish to retrieve the player count of. + +**Returns:** + +Returns an integer containing the number of players in the team, false if it could not be retrieved. +- int: value + +**Examples:** + +Example 1: This example adds a command in the console to find out how many players are on your team. +Example 2: This example adds a command in the console to find out how many players are on your team, clientside + +### Unknown + +**Description:** No description available + +### getAlivePlayers + +**Description:** This function returns a table of all the alive players on the server. Opposite function of [getDeadPlayers](/wiki/GetDeadPlayers "GetDeadPlayers"). + +**Returns:** + +Returns a table of all the alive players. +- table: value + +**Examples:** + +Example 1: This example prints a list of all alive players in a "name, name2, name3" format. If no players are alive then it outputs "none". + +### getControlState + +**Description:** This function will check if a player is pressing a particular control. Controls are those that affect GTA. If you wish to get the state of another key, use [bindKey](/wiki/BindKey "BindKey") and a command function. + +**Parameters:** + +- `thePlayer` (player): The player you wish to get the control state of. Do not use this parameter when scripting for client. +- `controlName` (string): The control that you want to get the state of. See control names for a list of possible controls. + +**Returns:** + +Returns the state of the control, false if the control doesn't exist or if the player is dead. +- bool: value + +**Examples:** + +Example 1: This example starts a repeating check when a player spawns, if a player presses the fire key, they'll be killed. + +### getDeadPlayers + +**Description:** This function returns a table of all currently dead players on the server. + +**Returns:** + +Returns a table of all the dead players. +- table: value + +**Examples:** + +Example 1: This example prints the list of dead players to the chat box. + + +*...and 53 more functions in this category* + +--- + + +### Projectile Functions + +*8 functions in this category* + +### createProjectile + +**Description:** This function creates a projectile of the specified type on the specified coordinates. + +**Parameters:** + +- `creator` (element): The element representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be the local player or his vehicle. +- `weaponType` (int): int representing the projectile weaponType (characteristics). Valid IDs are: +- `posX` (float): float starting coordinates for the projectile. They are coordinates of creator by default. +- `posY` (float): MISSING_PARAM_DESC +- `posZ` (float): MISSING_PARAM_DESC +- `force` (float): float representing the starting force for throwable projectiles. +- `target` (element): element target used for heat seeking rockets. +- `rotX` (float): float starting rotation for the projectile. +- `rotY` (float): MISSING_PARAM_DESC +- `rotZ` (float): MISSING_PARAM_DESC +- `velX` (float): float starting velocity for the projectile. +- `velY` (float): MISSING_PARAM_DESC +- `velZ` (float): MISSING_PARAM_DESC +- `model` (int): Integer representing the projectile's model, uses default model for weaponType if not specified. + +**Returns:** + +Returns a projectile element if projectile creation was successful. Returns false if unable to create a projectile (wrong weapon ID or projectiles limit was reached). +- projectile: value + +**Examples:** + +Example 1: This example makes a rocket minigun (minigun shooting with rockets). +Example 2: This example code shoots a projectile from your occupied vehicle that travels in the direction your vehicle is facing when you press vehicle_fire (left mouse button with default controls) + +### Unknown + +**Description:** No description available + +### getProjectileCounter + +**Description:** Get the time left before a projectile detonates. + +**Parameters:** + +- `projectile` (projectile): the projectile to get the timer of. + +**Returns:** + +Returns the the time in milliseconds to detonation which depending on the projectile type will do different things: +- int: value + +**Examples:** + +Example 1: With this example you can find out how long does it take for a projectile to explode/end + +### getProjectileCreator + +**Description:** This function returns the creator of the specified projectile. + +**Parameters:** + +- `theProjectile` (projectile): The projectile element which creator you want to retrieve. + +**Returns:** + +Returns the element which created the projectile if successful, false otherwise. +- element: value + +**Examples:** + +Example 1: This example will output a message in the chatbox saying who created +the projectile. + +### getProjectileForce + +**Description:** This function returns the force of the specified projectile. + +**Parameters:** + +- `theProjectile` (projectile): The projectile element which force you want to retrieve. + +**Returns:** + +Returns a float if successful, false otherwise. +- float: value + +**Examples:** + +Example 1: Example 1:This example would outputs the force of the projectile on 1-100 scale. This function just works with projectiles which you throw so just grenades, satchel charge etc + + +*...and 3 more functions in this category* + +--- + + +### Radar_area Functions + +*8 functions in this category* + +### Unknown + +**Description:** No description available + +### getRadarAreaColor + +**Description:** This function can be used to retrieve the current color of a [radar area](/wiki/Radararea "Radararea"). + +**Parameters:** + +- `theRadararea` (radararea): The radar area you wish to retrieve the colour of. + +**Returns:** + +Returns four integers in RGBA format ( red , green , blue , alpha ), with a maximum value of 255 for each. Alpha decides transparency where 255 is opaque and 0 is transparent. Returns false if the radararea is invalid. +- int: value1 +- int: value2 +- int: value3 +- int: value4 + +**Examples:** + +Example 1: This example checks the color of a radararea defined as 'area' and announces if it is Ballas or Grove Street territory. + +### getRadarAreaSize + +**Description:** This function is used for getting the X and Y size of an existing [radar area](/wiki/Radararea "Radararea"). + +**Parameters:** + +- `theRadararea` (radararea): The radar area element whose size you wish to get. + +**Returns:** + +Returns two floats indicating the X and Y length of the radar area respectively, false if the radar area is invalid. +- float: value1 +- float: value2 + +**Examples:** + +Example 1: The following example looks for radar areas whose size is smaller than 100 by 100: + +### isInsideRadarArea + +**Description:** This function checks if a 2D position is inside a [radar area](/wiki/Radararea "Radararea") or not. + +**Parameters:** + +- `theArea` (radararea): The radar area you're checking the position against. +- `posX` (float): The X coordinate of the position you're checking. +- `posY` (float): The Y coordinate of the position you're checking. + +**Returns:** + +Returns true if the position is inside the radar area, false if it isn't or if any parameters are invalid. +- bool: value + +**Examples:** + +Example 1: This function checks if an element is within a radar area. + +### isRadarAreaFlashing + +**Description:** This function allows detection of whether a radar area is flashing or not. + +**Parameters:** + +- `theRadararea` (radararea): The radar area you wish to check the state of flashing + +**Returns:** + +Returns true if the radar area is flashing, false if it is not or if it doesn't exist. +- bool: value + +**Examples:** + +Example 1: This example checks whether the radar area in the variableglenparkis flashing, and announces it if it is. + + +*...and 3 more functions in this category* + +--- + + +### Resource Functions + +*38 functions in this category* + +### abortRemoteRequest + +**Description:** Aborts a [fetchRemote](/wiki/FetchRemote "FetchRemote") or [callRemote](/wiki/CallRemote "CallRemote") request. + +**Parameters:** + +- `theRequest` (request): returned from fetchRemote , callRemote or getRemoteRequests + +**Returns:** + +Returns true on success, false when invalid request was provided +- bool: value + +**Examples:** + +Example 1: This example aborts all requests. + +### addResourceConfig + +**Description:** This function adds a new empty config file to an existing resource. + +**Parameters:** + +- `filePath` (string): The filepath of the file to be created in the following format: ":resourceName/path" . 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. +- `filetype` (string): a string indicating whether the file is serverside ("server") or clientside ("client"). + +**Returns:** + +Returns the new config's root xmlnode if the config was added successfully, false otherwise. +- xmlnode: value + +**Examples:** + + +### addResourceMap + +**Description:** This function adds a new empty mapfile to an existing resource. + +**Parameters:** + +- `filePath` (string): The filepath of the resource map in the following format: ":resourceName/path" . 'resourceName' is the name of the resource the map file will be in, and 'path' is the path from the root directory of the resource to the file. +- `dimension` (int): the dimension in which the map's objects will be placed. + +**Returns:** + +Returns the new map's root xmlnode if the map was added successfully, false otherwise. +- xmlnode: value + +**Examples:** + +Example 1: This example just adds a map to a gamemode resource called "cdm". + +### call + +**Description:** This function is used to call a function from another resource (which must be running). + +**Parameters:** + +- `theResource` (resource): This is a resource pointer which refers to the resource you are calling a function from. +- `theFunction` (string): This is a string with the name of the function which you want to call. +- `arguments...` (unknown): MISSING_PARAM_DESC + +**Returns:** + +Returns anything that the designated function has returned, if the function has no return, nil is returned. If the function does not exist, is not exported, or the call was not successful it will return false. +- var...: value + +**Examples:** + +Example 1: This extract shows adding of a "kills" column to the scoreboard resource. This then sets thegameShowKillsvariable to true(or false), telling the rest of the script to start outputting kills. +Example 2: This extract shows adding of a "kills" column to the scoreboard resource. This then sets thegameShowKillsvariable to true(or false), telling the rest of the script to start outputting kills. + +### callRemote + +**Description:** This function allows you to call functions that have been exported with HTTP access by other MTA servers. The calls are asynchronous so you do not get an immediate result from the call, instead a callback function you specify is called when the call returns. + +**Parameters:** + +- `host` (string): This is a host name - including the HTTP port - of the server you wish to connect to. +- `queueName` (string): MISSING_PARAM_DESC +- `connectionAttempts` (int): Number of times to retry if the remote host does not respond. In the case of a non-responding remote server, each connection attempt will timeout after 6 seconds. Therefore, the default setting of 10 connection attempts means it will be 60 seconds before your script gets a callback about the error. Reducing this value to 2 for example, will decrease that period to 12 seconds +- `connectTimeout` (int): Number of milliseconds each connection attempt will take before timing out +- `resourceName` (string): This is a name of the resource that contains the exported function you want to call. +- `functionName` (string): This is a string with the name of the function which you want to call. +- `callbackFunction` (callback): This is the function that should receive the data returned from the remote function call. The argument list should match the format of the data returned. The callback function will be passed a string containing "ERROR" followed by an integer indicating the error code when an error occurs calling the function. A list of error codes can be found here . +- `arguments...` (unknown): MISSING_PARAM_DESC + +**Returns:** + +Returns true if the function has been called, false otherwise. +- bool: value + +**Examples:** + +Example 1: PHP:(for the page that Lua expects to be athttp://www.example.com/page.php) +Example 2: Lua: + + +*...and 33 more functions in this category* + +--- + + +### SVG Functions + +*6 functions in this category* + +### svgCreate + +**Description:** Creates an [svg](/wiki/Svg "Svg") from size (blank document), filepath or raw data. + +**Parameters:** + +- `width` (int): Desired width, preferably power of two (16, 32, 64 etc.), maximum is 4096 +- `height` (int): MISSING_PARAM_DESC +- `string pathOrRawData, function callback ( element svg` ([,): MISSING_PARAM_DESC + +**Returns:** + +This is a basic example of how you can create an SVG from raw data (or path) and draw it with dxDrawImage via onClientRender . +- svg: value + +**Examples:** + +Example 1: This is a basic example of how you can create an SVG from raw data (or path) and draw it withdxDrawImageviaonClientRender. +Example 2: Here's another, more in-depth example which utilizes the callback argument. You can use the F2 key to set the SVG to a random size and see the update callback output a message to debugscript. + +### svgGetDocumentXML + +**Description:** Gets the underlying XML document from an SVG element. + +**Parameters:** + +- `svgElement` (svg): The svg element you want to get the XML document of. + +**Returns:** + +See the example for svgSetDocumentXML +- xmlnode: value + +### svgGetSize + +**Description:** Gets the underlying XML document from an SVG element. + +**Parameters:** + +- `svgElement` (svg): The svg you want to get the size of. + +**Returns:** + +See the example for svgSetSize . +- int: value1 +- int: value2 + +### svgSetDocumentXML + +**Description:** Sets the underlying XML document of an SVG element. + +**Parameters:** + +- `svgElement` (svg): The svg element you want to set the XML document of +- `xmlDocument` (xmlnode): An xmlnode containing the data to be set on the SVG document +- `function callback ( element svg` ([,): MISSING_PARAM_DESC + +**Returns:** + +This example creates an svg element including a keybind (F2) to add a child rect node, with the use of callbacks to notify in debugscript when the SVG was updated. +- bool: value + +**Examples:** + +Example 1: This example creates ansvgelement including a keybind (F2) to add a child rect node, with the use of callbacks to notify in debugscript when the SVG was updated. + +### svgSetSize + +**Description:** Sets the underlying XML document from an SVG element. + +**Parameters:** + +- `svgElement` (svg): The svg element you want to set the size of. +- `width` (int): Desired width, preferably power of two (16, 32, 64 etc.), maximum is 4096 +- `height` (int): MISSING_PARAM_DESC +- `function callback ( element svg` ([,): MISSING_PARAM_DESC + +**Returns:** + +This example creates an svg element including a keybind (F2) to resize the SVG randomly, with the use of callbacks to notify in debugscript when the SVG was updated. +- bool: value + +**Examples:** + +Example 1: This example creates ansvgelement including a keybind (F2) to resize the SVG randomly, with the use of callbacks to notify in debugscript when the SVG was updated. + + +*...and 1 more functions in this category* + +--- + + +### Searchlight Functions + +*9 functions in this category* + +### createSearchLight + +**Description:** This function creates a [searchlight](/wiki/Element/Searchlight "Element/Searchlight"). A [searchlight](/wiki/Element/Searchlight "Element/Searchlight") is a spotlight which looks like the one available in the Police Maverick. + +**Parameters:** + +- `startX` (float): the X coordinate where the searchlight light cone will start. +- `startY` (float): the Y coordinate where the searchlight light cone will start. +- `startZ` (float): the Z coordinate where the searchlight light cone will start. +- `endX` (float): the X coordinate of the direction where the searchlight will point to. +- `endY` (float): the Y coordinate of the direction where the searchlight will point to. +- `endZ` (float): the Z coordinate of the direction where the searchlight will point to. +- `startRadius` (float): the radius of the searchlight's light cone in its beginning. +- `endRadius` (float): the radius of the searchlight's light cone in its end. +- `renderSpot` (bool): if true , the searchlight will lighten the surface where it ends. + +**Returns:** + +If every argument is correct and the limit of 1000 searchlights has not been reached, this function returns a searchlight element . Otherwise, it returns false . +- searchlight: value + +**Examples:** + +Example 1: This example allows players to wear a helmet lantern, which can be toggled on or off by pressing O or using/togglelantern. It uses createSearchLight to create the illumination effect. + +### getSearchLightEndPosition + +**Description:** This function gets the end position of a [searchlight](/wiki/Element/Searchlight "Element/Searchlight") element. + +**Parameters:** + +- `theSearchLight` (searchlight): the searchlight to get the position where the searchlight's light cone ends. + +**Returns:** + +If the specified searchlight element is valid, this function will return three float , which are the three coordinates of searchlight's end position. If not, it will return false plus an error message. +- float float float: value + +**Examples:** + + +### getSearchLightEndRadius + +**Description:** This function gets the end radius of a [searchlight](/wiki/Element/Searchlight "Element/Searchlight") element. + +**Parameters:** + +- `theSearchLight` (searchlight): the searchlight to get the radius of the searchlight's light cone in its end. + +**Returns:** + +If the specified searchlight element is valid, this function will return one float , which is the searchlight's end radius. If not, it will return false plus an error message. +- float: value + +**Examples:** + + +### getSearchLightStartPosition + +**Description:** This function gets the start position of a [searchlight](/wiki/Element/Searchlight "Element/Searchlight") element. + +**Parameters:** + +- `theSearchLight` (searchlight): the searchlight to get the position where the searchlight's light cone starts. + +**Returns:** + +If the specified searchlight element is valid, this function will return three float , which are the three coordinates of searchlight's start position. If not, it will return false plus an error message. +- float: x +- float: y +- float: z + +**Examples:** + + +### getSearchLightStartRadius + +**Description:** This function gets the start radius of a [searchlight](/wiki/Element/Searchlight "Element/Searchlight") element. + +**Parameters:** + +- `theSearchLight` (searchlight): the searchlight to get the radius of the searchlight's light cone in its beginning. + +**Returns:** + +If the specified searchlight element is valid, this function will return one float , which is the searchlight's start radius. If not, it will return false plus an error message. +- float: value + +**Examples:** + + + +*...and 4 more functions in this category* + +--- + + +### Server Functions + +*13 functions in this category* + +### getMaxPlayers + +**Description:** This function returns the maximum number of player slots on the server. + +**Returns:** + +Returns the maximum number of players allowed on the server. +- int: value + +**Examples:** + +Example 1: This example outputs the current number of players together with the maximum number of players when a player joins. + +### getServerConfigSetting + +**Description:** This function retrieves server settings which are usually stored in the **mtaserver.conf** file. + +**Parameters:** + +- `name` (string): MISSING_PARAM_DESC + +**Returns:** + +Returns a string containing the current value for the named setting, table if name is module or false if the setting does not exist. If the setting name is serverip , may return the string "auto" on local servers. +- mixed: value + +**Examples:** + +Example 1: This example prints the server minimum allowed client version to the chatbox +Example 2: This example creates agetServerIPhelper function: + +### getServerHttpPort + +**Description:** This function retrieves the server's HTTP port. + +**Returns:** + +An integer corresponding to the server's HTTP port. +- int: value + +**Examples:** + +Example 1: This example outputs server's HTTP port to the chat box when player uses commandgetHttpPort + +### getServerIpFromMasterServer + +**Description:** This function returns the remote address as reported by the first master server that provides this value. + +**Returns:** + +A string containing the remote address of the server as reported, once it's available. +- string: value + +**Examples:** + +Example 1: This example creates a console command that outputs the server's IP to the chatbox. + +### getServerName + +**Description:** This function retrieves the server's name. + +**Returns:** + +A string containing the server's name. +- string: value + +**Examples:** + +Example 1: This example creates a console command that outputs the server's name to the chatbox. + + +*...and 8 more functions in this category* + +--- + + +### Settings_registry Functions + +*2 functions in this category* + +### get + +**Description:** This function gets a setting's value, or a group of settings' values, from the [settings registry](/wiki/Settings_system "Settings system"). + +**Parameters:** + +- `settingName` (string): MISSING_PARAM_DESC + +**Returns:** + +Returns the value of the setting if a single setting was specified and found, or a table (in associative-array form) containing: +- var: value + +**Examples:** + +Example 1: Example returns a value from the settings registry with the name "respawnTime". +Example 2: Or easier: + +### set + +**Description:** This function is used to save arbitrary data under a certain name on the [settings registry](/wiki/Settings_system "Settings system"). + +**Parameters:** + +- `settingName` (string): The name of the setting you want to set. See setting names for information on settings names. +- `value` (var): The value to set the setting to. This can be any Lua data type, except for functions, most userdata (only resources can't be stored) and threads. + +**Returns:** + +Returns true if the setting has been set, false if you do not have access to the setting or invalid arguments were passed. +- bool: value + +**Examples:** + +Example 1: This example sets a specified setting with a Value. This is alocalsetting belonging to the resource that the code is run in. + +--- + + +### Team Functions + +*8 functions in this category* + +### createTeam + +**Description:** This function is for creating a new [team](/wiki/Team "Team"), which can be used to group players. Players will not join the team until they are respawned. + +**Parameters:** + +- `teamName` (string): A string representing the teams name. +- `colorR` (int): An integer representing the red color value. +- `colorG` (int): An integer representing the green color value. +- `colorB` (int): An integer representing the blue color value. + +**Returns:** + +Returns a team element if it was successfully created, false if invalid arguments are passed or a team with that name already exists. +- team: value + +**Examples:** + +Example 1: Example 1:This example creates a new team for a player, then adds him to it. +Example 2: Example 2:This example creates two teams, one for Admin and one for Freeroamers, when the resource this script is in is started. + +### getTeamColor + +**Description:** This function retrieves the color of a team. + +**Parameters:** + +- `theTeam` (team): The team you want to get the color of. + +**Returns:** + +Returns 3 integers representing the red, green, and blue color components of the team if it's valid, false otherwise. +- int: value1 +- int: value2 +- int: value3 + +**Examples:** + +Example 1: This example defines a console command that outputs the player's team name and colors if he is on a team. + +### getTeamFriendlyFire + +**Description:** This function tells you if friendly fire is turned on for the specified team. + +**Parameters:** + +- `theTeam` (team): The team object that will be checked + +**Returns:** + +Returns true if friendly fire is on for the specified team, false if it is turned off or if invalid arguments are specified. +- bool: value + +**Examples:** + +Example 1: This example makes a command that checks if friendly fire is on for each team, and toggles it on if it isn't. + +### getTeamFromName + +**Description:** This function finds a [team](/wiki/Team "Team") element using the provided team name. + +**Parameters:** + +- `teamName` (string): A string determining the name of the team you wish to find. + +**Returns:** + +Returns the team element if it was found, false otherwise. +- team: value + +**Examples:** + +Example 1: This example creates a team, and sets the player's team to it's partial name: + +### getTeamName + +**Description:** This function gets the team name of a team object. + +**Parameters:** + +- `theTeam` (team): The team you want to retrieve the name of. + +**Returns:** + +Returns a string representing the team's name if the team object was valid, false otherwise. +- string: value + +**Examples:** + +Example 1: This example gets the current team of a player, then prints its name to the chatbox. + + +*...and 3 more functions in this category* + +--- + + +### Text Functions + +*20 functions in this category* + +### textCreateDisplay + +**Description:** A [text display](/wiki/Textdisplay "Textdisplay") is like a canvas that can contain many [items of text](/wiki/Textitem "Textitem"). Each display can be seen by multiple observers (players) and each player can see multiple displays. + +**Returns:** + +- textdisplay: value + +**Examples:** + + +### textCreateTextItem + +**Description:** This function creates a text item. A text item represents a single area of text, much like a label does in standard GUI programming. A text item can only be seen by players if it is added to a [textdisplay](/wiki/Textdisplay "Textdisplay") using [textDisplayAddText](/wiki/TextDisplayAddText "TextDisplayAddText"). Each text item can be added to multiple displays, if need be. + +**Parameters:** + +- `text` (string): A string of text you want to display +- `x` (float): A floating point number between 0.0 and 1.0 indicating how far across the screen the text should be shown, as a percentage of the width, from the left hand side. +- `y` (float): A floating point number between 0.0 and 1.0 indicating how far down the screen the text should be shown, as a percentage of the height, from the top. +- `priority` (string): How important it is that this text should be up to date on client's screens. Valid values are: "low", "medium", "high" which are aliases for 0, 1 and 2 respectively. +- `red` (int): A value between 0 and 255 indicating how red the text should be. +- `green` (int): A value between 0 and 255 indicating how green the text should be. +- `blue` (int): A value between 0 and 255 indicating how blue the text should be. +- `alpha` (int): A value between 0 and 255 indicating how transparent the text should be, with 0 being fully transparent, and 255 being opaque. +- `scale` (float): A floating point value indicating the scale of the text. The default is 1.0, which is around 12pt. +- `alignX` (string): A string representing the X-alignment of the text. ("left", "center", "right") +- `alignY` (string): A string representing the Y-alignment of the text. ("top", "center", "bottom") +- `shadowAlpha` (int): A value between 0 and 255 indicating how dark the drop shadow should be. + +**Returns:** + +Returns a textitem object. +- textitem: value + +**Examples:** + + +### textDestroyDisplay + +**Description:** This function destroys a text display and will unlink all the [textitems](/wiki/Textitem "Textitem") on it. This does not stop the textitems existing, but anyone who was observing the textitems through this display will stop seeing them. + +**Parameters:** + +- `display` (textdisplay): This is the textdisplay that you wish to have destroyed. + +**Returns:** + +- bool: value + +**Examples:** + +Example 1: This example creates a display then destroys it again straight away. + +### textDestroyTextItem + +**Description:** This function destroys a [textitem](/wiki/Textitem "Textitem") object. + +**Parameters:** + +- `theTextitem` (textitem): The text item you wish to destroy. + +**Examples:** + +Example 1: This example creates then destroys atextitem. + +### textDisplayAddObserver + +**Description:** This function adds a [player](/wiki/Player "Player") as an observer of a [textdisplay](/wiki/Textdisplay "Textdisplay"). This allows the [player](/wiki/Player "Player") to see any [textitems](/wiki/Textitem "Textitem") that the [textdisplay](/wiki/Textdisplay "Textdisplay") contains. + +**Parameters:** + +- `display` (textdisplay): The textdisplay to add the player to as an observer. +- `playerToAdd` (player): The player that should observe the textdisplay . + +**Examples:** + + + +*...and 15 more functions in this category* + +--- + + +### UTF8_Library Functions + +*21 functions in this category* + +### utf8.byte + +**Description:** Returns the codepoints for the i\-th through j\-th character of the string passed. + +**Parameters:** + +- `input` (string): A string character sequence. +- `i` (int): An integer representing the beginning position. +- `j` (int): An integer representing the ending position. + +**Returns:** + +Returns a sequence of integer values from the original string if successful, [[nil]] otherwise. +- int: value1 +- ...: values + +**Examples:** + +Example 1: This example will print every codepoint in the input string to the +console. + +Output: + +Codepoint @ 1 = 1053 +Codepoint @ 2 = 1080 +Codepoint @ 3 = 1094 +Codepoint @ 4 = 1094 +Codepoint @ 5 = 1072 +Codepoint @ 6 = 33 + + +Example 2: This example will print the codepoint of the first character (read: 'M') in the string literal. + +### utf8.char + +**Description:** Generates a string representing the character codepoints as arguments. + +**Parameters:** + +- `codepoints...` (int): An variable argument sequence of code points representing the desired unicode characters. + +**Returns:** + +Returns a [[string]] representation of the codepoints passed. +- string: value + +**Examples:** + +Example 1: This example separates an input string into single codepoints and then joins these back together, representing the original input string. +Example 2: This example takes three code points to generate the string "MTA". + +### utf8.charpos + +**Description:** Converts the UTF\-8 codepoint position to byte\-string position. + +**Parameters:** + +- `input` (string): A string character sequence. +- `charpos` (int): An integer representing the beginning position (offset will be added/subtracted). +- `offset` (int): An integer representing the offset to charpos. + +**Returns:** + +Returns the integer position as in a byte string and the integer codepoint at this position, [[nil]] otherwise. +- int: value1 +- int: value2 + +**Examples:** + +Example 1: This example takes the second codepoint character and shows the byte-string position and the codepoint character code. +Example 2: This example extracts the first character by calculating the character length with the UTF8 functions and the inbuilt Lua function string.sub, which processes byte strings. + +### utf8.escape + +**Description:** Escapes a string to a UTF\-8 format string. It supports several escape formats, see the formatting table. + +**Parameters:** + +- `input` (string): A string character sequence. + +**Returns:** + +Returns a [[string]] containing the escaped UTF-8 characters from the original string. +- string: value + +**Examples:** + +Example 1: This example escapes two byte-string literals to UTF-8 format by using the utf8.escape function. + +### utf8.find + +**Description:** Finds the first occurrence of the [pattern](http://lua-users.org/wiki/PatternsTutorial) in the string passed. If an instance of the pattern is found, a pair of values representing the start and the end of the matched string is returned. + +**Parameters:** + +- `input` (string): A string character sequence. +- `pattern` (string): A string match pattern (you can disable pattern matching by using the optional fourth argument plain ). +- `startpos` (int): An integer representing the beginning position. +- `plain` (boolean): A boolean, if pattern matching should be turned off + +**Returns:** + +Returns two number values for the beginning and ending position of the matched string, [[nil]] otherwise. +- int: start position +- int: end position + +**Examples:** + +Example 1: This example shows how to search for parts of a string. + + +*...and 16 more functions in this category* + +--- + + +### Utility Functions + +*83 functions in this category* + +### addDebugHook + +**Description:** This function allows tracing of MTA functions and events. It should only be used when debugging scripts as it may degrade script performance. + +**Parameters:** + +- `hookType` (string): The type of hook to add. This can be: preEvent postEvent preFunction postFunction preEventFunction postEventFunction +- `callbackFunction` (function): The function to call Returning the string "skip" from the callback function will cause the original function/event to be skipped +- `nameList` (table): Table of strings for restricting which functions and events the hook will be triggered on addDebugHook and removeDebugHook will only be hooked if they are specified in the name list + +**Returns:** + +Returns true if the hook was successfully added, or false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will dump info about all triggered events: +Example 2: This example will dump info about all called MTA functions: + +### bitAnd + +**Description:** This function performs a bitwise AND\-conjunction on two or more (unsigned) 32\-bit [integers](/wiki/Int "Int"). See [Bitwise operation](http://en.wikipedia.org/wiki/Bitwise_operation#AND) for more details. + +**Parameters:** + +- `var1` (uint): MISSING_PARAM_DESC +- `var2` (uint): MISSING_PARAM_DESC +- `...` (unknown): MISSING_PARAM_DESC + +**Returns:** + +Returns the conjuncted value. +- uint: value + +**Examples:** + + +### bitArShift + +**Description:** This functions performs an arithmetic shift on the integer **value** by integer **n** positions. In an *arithmetic shift*, zeros are shifted in to replace the discarded bits. In a *right arithmetic* shift, the [sign bit](https://en.wikipedia.org/wiki/Sign_bit) is shifted in on the left, thus preserving the sign of the operand. +See [Bitwise operation](https://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift) for more details. + +**Parameters:** + +- `value` (int): The value you want to perform the arithmetic shift on. +- `n` (int): The amount of positions to shift the value by. + +**Returns:** + +Returns the arithmetic shifted value as integer . +- int: value + +**Examples:** + +Example 1: This example adds the clientside command/arshift [value] [positions = 1], which will print the result from the functionbitArShift. + +### bitExtract + +**Description:** This function returns the unsigned number formed by the bits field to field \+ width \- 1 (range: 0\-31\). + +**Parameters:** + +- `var` (uint): The value +- `field` (int): The field number +- `width` (int): Number of bits to extract + +**Returns:** + +Returns the extracted value/bit sequence. +- uint: value + +**Examples:** + + +### bitLRotate + +**Description:** This functions performs a bitwise circular left\-rotation on the integer **value** by integer **n** positions. +See [Bitwise operation](https://en.wikipedia.org/wiki/Bitwise_operation#Rotate_no_carry) for more details. + +**Parameters:** + +- `value` (int): The value you want to perform the rotation on. +- `n` (int): The amount of positions to rotate the value by. + +**Returns:** + +Returns the circular left-rotated value as integer . +- int: value + +**Examples:** + +Example 1: This example shows the usage of the functionbitLRotate. + + +*...and 78 more functions in this category* + +--- + + +### Vehicle Functions + +*150 functions in this category* + +### addVehicleSirens + +**Description:** This function adds sirens to a vehicle. + +**Parameters:** + +- `theVehicle` (vehicle): The vehicle to add sirens +- `sirenCount` (int): The amount of siren points on the vehicle (8 maximum) +- `sirenType` (int): An integer between 1 and 6 (1: invisible, 2: single, 3+: dual) +- `flag360` (bool): Visible from all directions (applies to single type only) +- `checkLosFlag` (bool): Check line of sight between camera and light so it won't draw if blocked +- `useRandomiser` (bool): Randomise the light order, false for sequential +- `silentFlag` (bool): If you want the siren to be silent set this to true + +**Returns:** + +Returns true if sirens were successfully added to the vehicle, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example adds a siren for the vehicle, then sets two custom sirens at the top of the vehicle. And then removes the siren when getting out the vehicle. + +### addVehicleUpgrade + +**Description:** This function adds an upgrade to a [vehicle](/wiki/Vehicle "Vehicle"), e.g. nitrous, hydraulics. + +**Parameters:** + +- `theVehicle` (vehicle): The element representing the vehicle you wish to add the upgrade to. +- `upgrade` (string/int): The id of the upgrade you wish to add: 1000 to 1193 ( see Vehicle Upgrades ) or " all" to add all upgrades. + +**Returns:** + +Returns true if the upgrade was successfully added to the vehicle, otherwise false . +- bool: value + +**Examples:** + +Example 1: This serverside function allows the user to get an upgrade by typing a command: +Example 2: This client-side script gives vehicles a nitro upgrade whenever they pass through a certain collision shape: + +### areVehicleLightsOn + +**Description:** This function is used to find out whether the lights of the vehicle are on. + +**Parameters:** + +- `theVehicle` (vehicle): the vehicle you wish to retrieve the lights state of. + +**Returns:** + +Returns true if the lights are on, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example checks if your vehicle lights are on/off and tells you the reason + +### attachTrailerToVehicle + +**Description:** This function attaches a trailer type vehicle to a trailer\-towing\-type vehicle. + +**Parameters:** + +- `theVehicle` (vehicle): the vehicle you wish to attach a trailer to. +- `theTrailer` (vehicle): the trailer you wish to be attached. + +**Returns:** + +Returns true if the vehicle's were successfully attached, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example will create a trailer and a trailer tower, then attach them. + +### Unknown + +**Description:** No description available + + +*...and 145 more functions in this category* + +--- + + +### Water Functions + +*13 functions in this category* + +### createWater + +**Description:** Creates an area of [water](/wiki/Water "Water"). + +**Parameters:** + +- `x1` (float): MISSING_PARAM_DESC +- `y1` (float): MISSING_PARAM_DESC +- `z1` (float): MISSING_PARAM_DESC +- `x2` (float): MISSING_PARAM_DESC +- `y2` (float): MISSING_PARAM_DESC +- `z2` (float): MISSING_PARAM_DESC +- `x3` (float): MISSING_PARAM_DESC +- `y3` (float): MISSING_PARAM_DESC +- `z3` (float): MISSING_PARAM_DESC +- `x4` (float): MISSING_PARAM_DESC +- `y4` (float): MISSING_PARAM_DESC +- `z4` (float): MISSING_PARAM_DESC +- `bShallow` (bool): gives the water a shallow water effect. + +**Returns:** + +Returns a water element if successful, false otherwise. The water element can be repositioned with setElementPosition and destroyed with destroyElement . +- water: value + +**Examples:** + +Example 1: Example code for creating a water area to cover the entire San Andreas Map (flood the cities). Also,setWaterLevelis used to raise the existing rivers and lakes. +Example 2: This example creates water at the given coordinates and sets the height of the water level to 20 for when the client joins. + +### getWaterColor + +**Description:** This function returns the water color of the GTA world. + +**Returns:** + +Returns 4 ints , indicating the color of the water. (RGBA) +- int: value1 +- int: value2 +- int: value3 +- int: value4 + +**Examples:** + + +### getWaterLevel + +**Description:** This function allows you to retrieve the water level from a certain location. The water level is 0 in most places though it can vary (e.g. it's higher near the dam). + +**Parameters:** + +- `posX` (float): MISSING_PARAM_DESC +- `posY` (float): MISSING_PARAM_DESC +- `posZ` (float): MISSING_PARAM_DESC +- `ignoreDistanceToWaterThreshold` (bool): If set to false, this function returns false, if the difference between water level (without waves) and posZ is greater than 3.0 + +**Returns:** + +Returns an integer of the water level if the localPlayer /position is near the water (-3 to 20 on the Z coordinate) else false if there's no water near the localPlayer /position. +- float: value + +**Examples:** + +Example 1: This example will tell you what's the water level where the specified player is located. + +### getWaterVertexPosition + +**Description:** Gets the world position of a vertex (i.e. corner) of a [water](/wiki/Water "Water") area. Each water area is either a triangle or quad (rectangle) so each has 3 or 4 corners. + +**Parameters:** + +- `theWater` (water): the water element to get the vertex of +- `vertexIndex` (int): the index of the vertex whose position to get. Values range from 1 to 4 for a water quad, or 1 to 3 for a triangle. + +**Returns:** + +Returns the x, y and z coordinates of the specified vertex if successful, false otherwise. +- int int float: value + +**Examples:** + + +### getWaveHeight + +**Description:** This function returns the current wave height. + +**Returns:** + +Returns the height as a float , false otherwise. +- float: value + +**Examples:** + +Example 1: This example changes the wave height to the given amount. + + +*...and 8 more functions in this category* + +--- + + +### Weapon Functions + +*12 functions in this category* + +### getOriginalWeaponProperty + +**Description:** This function gets the original weapon property of the specified weapons specified weapon type. + +**Parameters:** + +- `weaponID/string weaponName` (int): MISSING_PARAM_DESC +- `weaponSkill` (string): MISSING_PARAM_DESC +- `property` (string): MISSING_PARAM_DESC + +**Returns:** + +On success: +- int: value + +**Examples:** + +Example 1: This example gets the default weapon range of the M4 at poor skill level + +### getSlotFromWeapon + +**Description:** This function allows you to identify the weapon slot that a weapon belongs to. + +**Parameters:** + +- `weaponid` (int): Weapon to find the weapon slot of. + +**Returns:** + +Returns an integer representing the given weapon ID's associated weapon slot, false if the ID was invalid. +- int: value + +**Examples:** + +Example 1: This will output to the chatbox what weapon slot a given weapon number belongs to when entered into the console (i.e. 'getWeaponSlot 10'). + +### getWeaponIDFromName + +**Description:** This function will obtain the ID of a particular weapon from its name. + +**Parameters:** + +- `name` (string): A string containing the name of the weapon. Names can be: (Case is ignored) + +**Returns:** + +Returns an int if the name matches that of a weapon, false otherwise. +- int: value + +**Examples:** + +Example 1: This example will give the player the weapon they specify 20 ammo whenever they type "weaponname" into the console. + +### getWeaponNameFromID + +**Description:** This function allows you to retrieve the name of a weapon from an ID. + +**Parameters:** + +- `id` (int): The ID you wish to retrieve the name of + +**Returns:** + +Returns a string of the name of the weapon or death type, false otherwise. Names will be like these: (Ignoring case) +- string: value + +**Examples:** + +Example 1: This example displays a death message in the format of "*Killerkilleddead(Weapon)" + +### getWeaponProperty + +**Description:** This function gets a weapon property of the specified [custom weapon](/wiki/Element/Weapon "Element/Weapon") (clientside only) or specified [player\-held weapon](/wiki/Weapons "Weapons") (both client and server). + +**Parameters:** + +- `weaponID/string weaponName` (int): MISSING_PARAM_DESC +- `weaponSkill` (string): MISSING_PARAM_DESC +- `property` (string): MISSING_PARAM_DESC + +**Returns:** + +On success: +- int: value + +**Examples:** + +Example 1: This example gets the weapon range of the M4 at poor skill level + + +*...and 7 more functions in this category* + +--- + + +### Weapon_creation Functions + +*14 functions in this category* + +### createWeapon + +**Description:** Creates a [custom weapon](/wiki/Element/Weapon "Element/Weapon") that can fire bullets. **Do not confuse this with player held weapons**. + +**Parameters:** + +- `theType` (string): The weapon type which can be: +- `x` (float): MISSING_PARAM_DESC +- `y` (float): MISSING_PARAM_DESC +- `z` (float): MISSING_PARAM_DESC + +**Returns:** + +Returns a custom weapon element, which represents a weapon floating at that position. +- weapon: value + +**Examples:** + +Example 1: This example adds a/createminiguncommand to create a weapon that is always firing. + +### fireWeapon + +**Description:** Fires one shot from a [custom weapon](/wiki/Element/Weapon "Element/Weapon"). + +**Parameters:** + +- `theWeapon` (weapon): The weapon to be fired. + +**Returns:** + +Returns true if the shot weapon is valid and therefore the shot was fired, false otherwise. +- bool: value + +**Examples:** + +Example 1: This function creates and fires a weapon. +Example 2: This example will create an M4, attach it to the local player and fire it every frame. Be aware that neither the weapon nor the shots are synced between players and that normally weapons don't fire every frame. + +### getWeaponAmmo + +**Description:** This function gets the total ammo a [custom weapon](/wiki/Element/Weapon "Element/Weapon") has. + +**Parameters:** + +- `theWeapon` (weapon): The weapon to get the ammo of. + +**Returns:** + +Returns an integer containing how many ammo left has the weapon. Returns false if an error occured. +- int: value + +**Examples:** + +Example 1: This example gets the ammo of the custom weapon and outputs it to the chatbox. + +### getWeaponClipAmmo + +**Description:** This function gets the amount of ammo left in a [custom weapon](/wiki/Element/Weapon "Element/Weapon")'s magazine/clip. + +**Parameters:** + +- `theWeapon` (weapon): the weapon to get the clip ammo of. + +**Returns:** + +Returns the amount of ammo in the custom weapon 's clip, false if an error occured. +- int: value + +**Examples:** + +Example 1: This function outputs the remaining ammo in clip of a specific weapon using the command/getammoinclip. + +### getWeaponFiringRate + +**Description:** This gets the firing rate to be used when a [custom weapon](/wiki/Element/Weapon "Element/Weapon") opens fire. + +**Parameters:** + +- `theWeapon` (weapon): The weapon to modify the firing rate of. + +**Returns:** + +Returns an integer with the firing rate of the custom weapon, false otherwise. +- int: value + +**Examples:** + +Example 1: This example creates a minigun at the center of the map and creates a/fireratecommand that outputs its firerate to the player who types it. + + +*...and 9 more functions in this category* + +--- + + +### World Functions + +*117 functions in this category* + +### areTrafficLightsLocked + +**Description:** Gets whether the traffic lights are currently locked or not. If the lights are locked, it means they won't change unless you do [setTrafficLightState](/wiki/SetTrafficLightState "SetTrafficLightState"). + +**Returns:** + +Returns true the traffic lights are currently locked, false otherwise. +- bool: value + +**Examples:** + +Example 1: This example toggles traffic lights between 'locked' and 'unlocked'. + +### createSWATRope + +**Description:** Creates a SWAT rope like that of the rope in single player used by SWAT Teams abseiling from the Police Maverick. + +**Parameters:** + +- `fx` (float): MISSING_PARAM_DESC +- `fy` (float): MISSING_PARAM_DESC +- `fZ` (float): MISSING_PARAM_DESC +- `duration` (int): the amount in miliseconds the rope will be there before falling to the ground. + +**Returns:** + +- bool: value + +**Examples:** + +Example 1: This example creates a Swat rope in police maverick when you use the command /createrope + +### getAircraftMaxHeight + +**Description:** This function gets the maximum height at which aircraft can fly without their engines turning off. + +**Returns:** + +Returns a float containing the max aircraft height. +- float: value + +**Examples:** + +Example 1: This example returns the max aircraft height to a player if they use the command 'aircraftmaxheight'. + +### getAircraftMaxVelocity + +**Description:** This function returns the maximum velocity at which aircrafts could fly. Using this function server\-side will return the server\-side value, not necessarily the same that is set client\-side. + +**Returns:** + +Returns a float being the max velocity that is currently set, depending on which side it is used. +- float: value + +**Examples:** + +Example 1: This example will increase or decrease the max velocity by pressing numpad keys + or -. +Example 2: This example will tell the max velocity to everyone when the resource is started. + +### getBirdsEnabled + +**Description:** This function will tell you if the birds are enabled or disabled. + +**Returns:** + +Returns true if the birds are enabled or false if the birds are disabled. +- bool: value + +**Examples:** + + + +*...and 112 more functions in this category* + +--- + + +### XML Functions + +*18 functions in this category* + +### xmlCopyFile + +**Description:** This function copies all contents of a certain node in a XML document to a new document file, so the copied node becomes the new file's root node. The new file will not be saved to file system until [xmlSaveFile](/xmlSaveFile) is called. + + +**Parameters:** + +- `nodeToCopy` (xmlnode): The [xmlnode](/xmlnode) that is to be copied to a new document. +- `newFilePath` (string): the path of the file that is to be created, in the following format: `":resourceName/path"`. `'resourceName'` is the name of the resource the file is in, and `'path'` is the path from the root directory of the resource to the file. +If the file is to be in the current resource, only the file path is necessary, e.g. `"newfile.xml"`. +For example, to create a file named `'newfile.xml'` with myNode as the root node in the resource `'ctf'`, it can be done from another resource this way: `xmlCopyFile(myNode, ":ctf/newfile.xml")`. +If the file is to be in the current resource, only the file path is necessary, e.g. `xmlCopyFile(myNode, "newfile.xml")`. + + +**Returns:** + +Returns the [xmlnode](/xmlnode) of the copy if the node was successfully copied, **false** if invalid arguments were passed. + +- xmlnode|false: xmlnode + +**Examples:** + +Example 1: In this example we will load an xml file (in the example config.xml) and create a copy in a new folder with the name of copy-config.xml. + +Example 2: In this example we will load an xml file (in the example config.xml) and create a copy in a new folder with the name of copy-config.xml. + + +### xmlCreateChild + +**Description:** This function creates a new child node under an XML node. + + +**Parameters:** + +- `parentNode` (xmlnode): The [xmlnode](/xmlnode) you want to create a new child node under. +- `tagName` (string): The type of the child node that will be created. + +**Returns:** + +Returns the created [xmlnode](/xmlnode) if successful, **false** otherwise. + +- xmlnode|false: xmlnode + +### xmlCreateFile + +**Description:** This function creates a new XML document, which can later be saved to a file by using [xmlSaveFile](/xmlSaveFile). This function will overwrite the file specified if it already exists. + + +**Parameters:** + +- `filePath` (string): The [Filepath](/reference/Filepath) of the file in the following format: **":resourceName/path"**. *resourceName* is the name of the resource the file will be in, and *path* is the path from the root directory of the resource to the file. For example, if you want to create a file named *new.xml* in the resource *ctf*, it can be created from another resource this way [xmlCreateFile](/xmlCreateFile)(":ctf/new.xml", "newroot"). If the file is in the current resource, only the file path is necessary, e.g. [xmlCreateFile](/xmlCreateFile)("new.xml", "newroot"). Note that if a different resource than default is being accessed, the caller resource needs access to **general.ModifyOtherObjects** in the [ACL](/ACL). + +- `rootNodeName` (string): The name of the root node in the XML document. + +**Returns:** + +Returns the root [xmlnode](/xmlnode) object of the new XML file if successful, or **false** otherwise. + +- xmlnode|false: xmlnode + +### xmlDestroyNode + +**Description:** This function destroys a XML node from the XML node tree. + + +**Parameters:** + +- `theXMLNode` (xmlnode): The [xmlnode](/xmlnode) you want to destroy. + +**Returns:** + +Returns **true** if the xml node was successfully destroyed, **false** otherwise. + +- bool: bool + +### xmlFindChild + +**Description:** This function returns a named child node of an XML node. + + +**Parameters:** + +- `parentNode` (xmlnode): This is an [xmlnode](/xmlnode) that you want to find the child node under. +- `tagName` (string): This is the name of the child node you wish to find (case-sensitive). +- `index` (int): This is the 0-based index of the node you wish to find. For example, to find the 5th subnode with a particular name, you would use 4 as the index value. To find the first occurence, use 0. + + +**Returns:** + +Returns an [xmlnode](/xmlnode) if the node was found, **false** otherwise. + +- xmlnode|false: xmlnode + +**Examples:** + +Example 1: If you wanted to find an instructions node in an xml file like this: +```xml + + + Start at the beginning and keep going until the end! + + +``` + +You could use the following code to print the text in the instructions node to the chatbox: + +Example 2: If you wanted to find an instructions node in an xml file like this: +```xml + + + Start at the beginning and keep going until the end! + + +``` + +You could use the following code to print the text in the instructions node to the chatbox: + + + +*...and 13 more functions in this category* + +--- + + +## Events + +Events are triggered when specific actions occur in the game. You can attach event handlers to respond to these events. + + +### Account Events + +*3 events in this category* + +### onAccountCreate + +**Type:** server + +**Description:** This event is triggered every time an [account](/wiki/Account "Account") is created + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `theAccount` (account): An account element that was created + +**Examples:** + +This example prints a message every time new account is created. + +### onAccountDataChange + +**Type:** server + +**Description:** This event is triggered when an accounts data changes through [setAccountData](/wiki/SetAccountData "SetAccountData"). + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `theAccount` (account): the account that had data changed. +- `theKey` (string): the string key that is being changed. +- `theValue` (string): the value it is changing to. + +**Examples:** + +This examples prevents the key of "level" being added or changed on every account. + +### onAccountRemove + +**Type:** server + +**Description:** This event is triggered every time an [account](/wiki/Account "Account") is removed + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `theAccount` (account): An account element that was removed + +**Examples:** + +This example prints a message every time new account is created. + +--- + + +### Browser Events + +*11 events in this category* + +### onClientBrowserCreated + +**Type:** client + +**Description:** This event is triggered when the CEF browser instance has been created. If you want to load a specific website right after creating the browser (using [createBrowser](/wiki/CreateBrowser "CreateBrowser") or [guiCreateBrowser](/wiki/GuiCreateBrowser "GuiCreateBrowser")), this event will be the convenient place. + +**Source Element:** element +The browser element. + +**Examples:** + + +### onClientBrowserCursorChange + +**Type:** client + +**Description:** This event is triggered when the cursor changes within a browser window. + +**Source Element:** element +The source of this event is the browser element the cursor change occured in. + +**Parameters:** + +- `cursorId` (int): The new cursor ID. See Cursor IDs. + +**Examples:** + + +### onClientBrowserDocumentReady + +**Type:** client + +**Description:** This event is executed after the web page has been loaded successfully. + +**Source Element:** element +The browser element. + +**Parameters:** + +- `url` (string): the url of the web page loaded. + +**Examples:** + + + +*...and 8 more events in this category* + +--- + + +### Client Events + +*1 events in this category* + +### onConsole + +**Type:** server + +**Description:** This event is triggered when a player types a message into his console. It is also triggered when entering '/' commands via the chatbox. + +**Source Element:** element +The source of this event is the player that entered the message in the console. This can be a player or the server console. + +**Parameters:** + +- `theMessage` (string): a string representing the message entered into the console. + +**Examples:** + + +--- + + +### Colshape Events + +*4 events in this category* + +### onClientColShapeHit + +**Type:** client + +**Description:** This event is triggered when a physical [element](/wiki/Element "Element") hits a [colshape](/wiki/Colshape "Colshape"). + +**Source Element:** element +The source of this event is the colshape that was hit. + +**Parameters:** + +- `theElement` (element): the element that entered the colshape. +- `matchingDimension` (bool): a boolean referring to whether the hit collision shape was in the same dimension as the element. + +**Examples:** + +This example outputs "In." to the chatbox whenever the local user enters a collision shape. + +### onClientColShapeLeave + +**Type:** client + +**Description:** This event is triggered when a physical [element](/wiki/Element "Element") leaves a [colshape](/wiki/Colshape "Colshape"). + +**Source Element:** element +The source of this event is the colshape that the element left. + +**Parameters:** + +- `theElement` (element): the element that left the colshape. +- `matchingDimension` (bool): a boolean referring to whether the collision shape was in the same dimension as the element. + +**Examples:** + +This example outputs "Out." to the chatbox whenever the local user leaves a collision shape. + +### onColShapeHit + +**Type:** server + +**Description:** This event is triggered when a physical [element](/wiki/Element "Element") hits a [colshape](/wiki/Colshape "Colshape"). + +**Source Element:** element +The source of this event is the colshape that got hit by a player or vehicle. + +**Parameters:** + +- `hitElement` (element): the element that entered the colshape. +- `matchingDimension` (bool): a boolean referring to whether the hit collision shape was in the same dimension as the element. + +**Examples:** + +This example creates a hill area for aKing of the hillgamemode. When a player enters or leaves the area, it's announced in the chatbox. + + +*...and 1 more events in this category* + +--- + + +### Element Events + +*19 events in this category* + +### onClientElementColShapeHit + +**Type:** client + +**Description:** This event is triggered when an element (like a player or vehicle) enters a collision shape. + +**Source Element:** element +The source of this event is the element that entered the colshape. + +**Parameters:** + +- `theShape` (colshape): the colshape that the element entered. +- `matchingDimension` (bool): true if the element is in the same dimension as the colshape, false otherwise. + +**Examples:** + +This example tells player when he/she entered any collision shapes that were created. + +### onClientElementColShapeLeave + +**Type:** client + +**Description:** This event is triggered when an element (like a player or vehicle) leaves a collision shape. + +**Source Element:** element +The source of this event is the element that left the colshape. + +**Parameters:** + +- `theShape` (colshape): the colshape that the element left. +- `matchingDimension` (bool): true if the element is in the same dimension as the colshape, false otherwise. + +**Examples:** + +This example tells player when he/she left any collision shapes that were created. + +### onClientElementDataChange + +**Type:** client + +**Description:** This event is triggered *after* an element's [data](/wiki/Element_data "Element data") entry is changed. Such changes can be made on the client or the server using [setElementData](/wiki/SetElementData "SetElementData"). + +**Source Element:** element +The source of this event is the element whose element data changed. + +**Parameters:** + +- `theKey` (string): The name of the element data entry that has changed. +- `oldValue` (var): The old value of this entry before it changed. See element data for a list of possible datatypes. +- `newValue` (var): the new value of this entry after it changed. This will be equivalent to getElementData(source, theKey). + +**Examples:** + +This example tells the client whenever a player's "score" element data is changed. + + +*...and 16 more events in this category* + +--- + + +### Input Events + +*23 events in this category* + +### onClientCharacter + +**Type:** client + +**Description:** This event triggers whenever the user presses an alphanumeric character on their keyboard. This also includes special characters, ie. **" / \# % \[ ] { }**. + +**Source Element:** element +The source of this event is the client's root element. + +**Parameters:** + +- `character` (string): a string representing the pressed character. + +**Examples:** + +This example will output the pressed character in the chatbox. + +### onClientClick + +**Type:** client + +**Description:** This event triggers whenever the user clicks his mouse. This is linked to the GTA world, as oppose to GUI for which [onClientGUIClick](/wiki/OnClientGUIClick "OnClientGUIClick") is to be used. This event allows detection of click positions of the 3D world. + +**Source Element:** element +The source of this event is the client's root element. + +**Parameters:** + +- `button` (string): This refers the button used to click on the mouse, can be left, right, or middle. +- `state` (string): This can be used to tell if the user released or pressed the mouse button, where up is passed if the button is released, and down is passed if the button is pushed. +- `absoluteX` (int): This refers to the 2D x coordinate the user clicked on his screen, and is an absolute position in pixels. +- `absoluteY` (int): This refers to the 2D y coordinate the user clicked on his screen, and is an absolute position in pixels. +- `worldX` (float): This represents the 3D x coordinate the player clicked on the screen, and is relative to the GTA world. +- `worldY` (float): This represents the 3D y coordinate the player clicked on the screen, and is relative to the GTA world. +- `worldZ` (float): This represents the 3D z coordinate the player clicked on the screen, and is relative to the GTA world. +- `clickedWorld` (element): This represents any physical entity elements that were clicked. If the player clicked on no MTA element, it's set to false. + +**Examples:** + +This example creates a label when an element is clicked, the label displays in the position of the element telling you what kind of element you have clicked. It hides after 5 seconds. + +### onClientCursorMove + +**Type:** client + +**Description:** This event is called by the root element whenever the cursor is moved over the screen, by the player. It returns information about the world coordinates as well as the screen coordinates of where the player moved the cursor. + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `cursorX` (float): the relative X coordinate of the mouse cursor. 0 = left side of the screen, 1 = right side. +- `cursorY` (float): the relative Y coordinate of the mouse cursor. 0 = top of the screen, 1 = bottom. +- `absoluteX` (int): the X coordinate of the mouse cursor, in pixels, measured from the left side of the screen. +- `absoluteY` (int): the Y coordinate of the mouse cursor, in pixels, measured from the top of the screen. +- `worldX` (float): the 3D in-game world X coordinate that the cursor is pointing at. +- `worldY` (float): the 3D in-game world Y coordinate that the cursor is pointing at. +- `worldZ` (float): the 3D in-game world Z coordinate that the cursor is pointing at. + +**Examples:** + +This example creates a text label at the bottom of the screen which displays the mouse position in pixels. + + +*...and 20 more events in this category* + +--- + + +### Marker Events + +*4 events in this category* + +### onClientMarkerHit + +**Type:** client + +**Description:** This event is triggered when a player enters a marker created using [createMarker](/wiki/CreateMarker "CreateMarker"). + +**Source Element:** element +The source of this event is the marker that got hit by the player. + +**Parameters:** + +- `hitPlayer` (player): the player that hit the marker. +- `matchingDimension` (bool): true if the player is in the same dimension as the hit marker. + +**Examples:** + +This code will output a message to the chatbox whenever any player walks into any marker. + +### onClientMarkerLeave + +**Type:** client + +**Description:** This event is triggered when a player leaves the area of a marker created using [createMarker](/wiki/CreateMarker "CreateMarker"). + +**Source Element:** element +The source of this event is the marker that the player left. + +**Parameters:** + +- `leftPlayer` (player): the player that left the marker's area. +- `matchingDimension` (bool): true if the player is in the same dimension as the marker. + +**Examples:** + +This example shows a message in the chatbox whenever a player leaves any marker. + +### onMarkerHit + +**Type:** server + +**Description:** This event is triggered when an element enters a marker created using [createMarker](/wiki/CreateMarker "CreateMarker"). + +**Source Element:** element +The source of this event is the marker that got hit by the element. + +**Parameters:** + +- `hitElement` (element): the element that hit the marker. +- `matchingDimension` (bool): a boolean representing whether the element is in the same dimension as the marker. + +**Examples:** + +This example will output a message what type of element has entered a marker. + + +*...and 1 more events in this category* + +--- + + +### Object Events + +*4 events in this category* + +### onClientObjectBreak + +**Type:** client + +**Description:** This event is fired before an object breaks. + +**Source Element:** element +The source of this event is the object which will break. + +**Parameters:** + +- `attacker` (element): the vehicle/ped/player who is breaking the object + +**Examples:** + +This example prevents objects from beeing broken in interiors. + +### onClientObjectDamage + +**Type:** client + +**Description:** This event is fired before an object gets damaged. + +**Source Element:** element +The source of this event is the object which was damaged. + +**Parameters:** + +- `loss` (float): the health loss caused by the damage. This parameter contains the theoretical loss, which could be less than 0, if you substract it of the current health. If you want to get the real loss, you have to substract the new health of the old health (use a timer for this). +- `attacker` (element): the vehicle/ped/player who is damaging the object. + +**Examples:** + +This example outputs the theoretical and real loss: + +### onClientObjectMoveStart + +**Type:** client + +**Description:** This event is triggered when an [object](/wiki/Object "Object") starts moving. + +**Source Element:** element +The source of this event is the object which was moved. + +**Examples:** + + + +*...and 1 more events in this category* + +--- + + +### Other Events + +*17 events in this category* + +### onClientChatMessage + +**Type:** client + +**Description:** This event is triggered when any text is output to chatbox, including MTA's internal messages. + +**Source Element:** element +The source of this event is either a player element or the root element. + +**Parameters:** + +- `text` (string): The text that was output to chatbox. +- `r` (int): The amount of red in the color of the text. +- `g` (int): The amount of green in the color of the text. +- `b` (int): The amount of blue in the color of the text. +- `messageType` (int): The type of message as a number. +0: normal message +1: action message (/me) +2: team message +3: private message +4: internal message + +**Examples:** + +This example doesn't output anything to chatbox if it consists only of numbers + +### onClientConsole + +**Type:** client + +**Description:** This event is triggered when the local player enters text in the console. Note that, if you want to add custom console commands, it is easier to use the [addCommandHandler](/wiki/AddCommandHandler "AddCommandHandler") function. + +**Source Element:** element +The source of this event is the localPlayer player element. + +**Parameters:** + +- `text` (string): the text line that was entered. + +**Examples:** + +This example outputs any text you input into the console. + +### onClientCoreCommand + +**Type:** client + +**Description:** This event is triggered when a built\-in client command is used, check [Client Commands](/wiki/Client_Commands "Client Commands"). + +**Source Element:** element +The source of this event is the localPlayer player element. + +**Parameters:** + +- `command` (string): The command that was executed. + +**Examples:** + +This example outputs the name of the command used. + + +*...and 14 more events in this category* + +--- + + +### Ped Events + +*14 events in this category* + +### onClientPedChoke + +**Type:** client + +**Description:** This event is fired when a ped chokes due to the effect of a weapon such as tear gas grenades, fire extinguishers and spray cans. + +**Source Element:** element +The source of this event is the ped who is choking. + +**Parameters:** + +- `weaponID` (int): an int representing the ID of the weapon which caused the choking. +- `responsiblePed` (ped): the ped responsible for causing the choking, possiblly nil. + +**Examples:** + +This example disables choking effects from the tear gas grenades. + +### onClientPedDamage + +**Type:** client + +**Description:** This event is triggered whenever a [ped](/wiki/Ped "Ped") is damaged. + +**Source Element:** element +The source of this event is the ped that got damaged + +**Parameters:** + +- `attacker` (element): A player element representing the attacker or vehicle element (when a ped falls of a bike). +- `weapon` (int): An integer representing the weapon ID the attacker used +- `bodypart` (int): An integer representing the bodypart the ped was damaged +3: Torso +4: Ass +5: Left Arm +6: Right Arm +7: Left Leg +8: Right Leg +9: Head +- `loss` (float): A float representing the percentage of health the ped lost. + +**Examples:** + +This example cancels any damage done to peds + +### onClientPedHeliKilled + +**Type:** client + +**Description:** This event is fired when a ped is killed due to the effect of a helicopter blades. + +**Source Element:** element +The source of this event is the ped who was killed + +**Parameters:** + +- `killer` (vehicle): the vehicle (heli) responsible for causing the death. + +**Examples:** + +This example disables helicopter killing + + +*...and 11 more events in this category* + +--- + + +### Pickup Events + +*6 events in this category* + +### onClientPickupHit + +**Type:** client + +**Description:** This event triggers whenever a pickup is hit clientside. + +**Source Element:** element +The source of this event is the pickup that was hit. + +**Parameters:** + +- `thePlayer` (player): the player that hit the pickup +- `matchingDimension` (bool): true if thePlayer is in the same dimension as the pickup, false otherwise. + +**Examples:** + +This example outputs a message whenever a player hits a pickup locally. + +### onClientPickupLeave + +**Type:** client + +**Description:** This event triggers whenever a pickup is left clientside. + +**Source Element:** element +The source of this event is the pickup that was left. + +**Parameters:** + +- `thePlayer` (player): the player that left the pickup +- `matchingDimension` (bool): true if thePlayer is in the same dimension as the pickup, false otherwise. + +**Examples:** + +This example outputs a message whenever a player leaves a pickup locally. + +### onPickupHit + +**Type:** server + +**Description:** This event is triggered when a [player](/wiki/Player "Player") hits a [pickup](/wiki/Pickup "Pickup"). + +**Source Element:** element +The source of this event is the pickup that was hit by the player. + +**Parameters:** + +- `thePlayer` (player): a player element referring to the player who moved over the pickup. + +**Examples:** + +This example creates a pickup and outputs a message to the chat box when a player walks over it. + + +*...and 3 more events in this category* + +--- + + +### Player Events + +*68 events in this category* + +### onClientPlayerChangeNick + +**Type:** client + +**Description:** This event is triggered when a player changes his nickname. + +**Source Element:** element +The source of this event is the player that changed his nick + +**Parameters:** + +- `oldNick` (string): the nickname the player had before. +- `newNick` (string): the new nickname of the player. + +**Examples:** + +This example snippet sends a lame message every time the local player changes his nick. + +### onClientPlayerChoke + +**Type:** client + +**Description:** This event is fired when the local player chokes due to the effect of a weapon such as tear gas grenades, fire extinguishers and spray cans. + +**Source Element:** element +The source of this event is the player who is choking. (Local player only) + +**Parameters:** + +- `weaponID` (int): an int representing the ID of the weapon which caused the choking. + +**Examples:** + +This example disables choking effects from the tear gas grenades. + +### onClientPlayerDamage + +**Type:** client + +**Description:** This event is triggered whenever a player is damaged. + +**Source Element:** element +The source of this event is the player that got damaged. (Streamed in players only) + +**Parameters:** + +- `attacker` (element): A player element representing the attacker or vehicle element (when being run over or falling off a bike). +- `damage_causing` (int): An int representing the cause of damage, either a attacker weapon, or some other types of damage. +- `bodypart` (int): An integer representing the bodypart the player was damaged. +3: Torso +4: Ass +5: Left Arm +6: Right Arm +7: Left Leg +8: Right Leg +9: Head +- `loss` (float): A float representing the percentage of health the player lost. + +**Examples:** + +This example prevents any damage from the minigun. + + +*...and 65 more events in this category* + +--- + + +### Projectile Events + +*1 events in this category* + +### onClientProjectileCreation + +**Type:** client + +**Description:** This event is triggered when a [projectile](/wiki/Projectile "Projectile") is created. + +**Source Element:** element +The source of this event is the projectile that was created. + +**Parameters:** + +- `creator` (element): the element that created the projectile. + +**Examples:** + +This will output a chatbox message when someone creates a projectile. + +--- + + +### Resource Events + +*9 events in this category* + +### onClientResourceFileDownload + +**Type:** client + +**Description:** This event is triggered every time a [resource](/wiki/Resource "Resource") file download is queued, finished or has failed. + +**Source Element:** element +The source of this event is the resource's root element. + +**Parameters:** + +- `fileResource` (resource): Resource the file belongs to. +- `fileName` (string): Relative resource file path. +- `fileSize` (int): Size of the file in bytes. +- `state` (string): Possible values: "queued" or "finished" or "failed". + +**Examples:** + +This example will output the file's resource name/file name/size/state when downloading: + +### onClientResourceStart + +**Type:** client + +**Description:** This event is triggered when a [resource](/wiki/Resource "Resource") is started. Please note that this is **not** triggered the same time as the serverside event [onResourceStart](/wiki/OnResourceStart "OnResourceStart") is. The event is triggered when any *clientside resources* are started. This means it is triggered when a clientside script is initiated after a download, which includes downloading after join. So: + +**Source Element:** element +The source of this event is the started resource's root element. + +**Parameters:** + +- `startedResource` (resource): the resource that was started. + +**Examples:** + +This example outputs name of resource that was started. + +### onClientResourceStop + +**Type:** client + +**Description:** This event is triggered when a [resource](/wiki/Resource "Resource") is being stopped. + +**Source Element:** element +The source of this event is the stopped resource root element. + +**Parameters:** + +- `stoppedResource` (resource): the resource that is about to get stopped. + +**Examples:** + +This example outputs name of resource that was stopped. + + +*...and 6 more events in this category* + +--- + + +### Server Events + +*7 events in this category* + +### onBan + +**Type:** server + +**Description:** This event is triggered when an IP address or serial is banned from the server. + +**Source Element:** element +The source of this event is the element that was responsible for the banning. If no responsible was specified, the source is the global root element. + +**Parameters:** + +- `theBan` (ban): the ban which was added. + +**Examples:** + +This example outputs a simple message to all players when a player added a ban. + +### onChatMessage + +**Type:** server + +**Description:** This event is triggered when any message is output to chat using [outputChatBox](/wiki/OutputChatBox "OutputChatBox") server\-side (also when a player uses *say*, *teamsay* or *me* successfully). + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `theMessage` (string): A string representing the text that was output to the chatbox. +- `theElement` (element): A resource if it was done via outputChatBox or a player element if it was done via say, teamsay or me. + +**Examples:** + +This example outputs all chat messages to debug view. + +### onDebugMessage + +**Type:** server + +**Description:** This event is triggered when debug messages (for instance errors or warnings) appear in the server console. + +**Source Element:** element +The source of this event is the root element. + +**Parameters:** + +- `message` (string): the message which was outputted in the server console, without details like file, line etc. +- `level` (int): the type of debug message which was outputted. +0: "Custom" message. +1: Error message. +2: Warning message. +3: Information message. +- `file` (string): the file from which the debug message was outputted. +Note: may return nil when the source could not be found. +- `line` (int): the line in file file where the debug message was outputted. +Note: may return nil when the source could not be found. +- `r` (int): an int representing the amount of red color (0-255). +- `g` (int): an int representing the amount of green color (0-255). +- `b` (int): an int representing the amount of blue color (0-255). + +**Examples:** + +This example outputs error debug messages to chat. + + +*...and 4 more events in this category* + +--- + + +### Sound Events + +*6 events in this category* + +### onClientSoundBeat + +**Type:** client + +**Description:** This event is triggered when a **sound** beats. + +**Source Element:** element +The source of this event is the sound's element. + +**Parameters:** + +- `theTime` (double): the position in the song of the beat + +**Examples:** + +This code will change the vehicle color to a random value if the sound beats and the localPlayer is inside a vehicle + +### onClientSoundChangedMeta + +**Type:** client + +**Description:** This event is triggered when a sound's meta tags have been modified. + +**Source Element:** element +The source of this event is the sound of which the meta tags have just been modified. + +**Parameters:** + +- `streamTitle` (string): The title of a specific stream + +**Examples:** + +This example will output the new stream title in the chatbox. + +### onClientSoundFinishedDownload + +**Type:** client + +**Description:** This event is triggered when a sound has just finished downloading. This means the complete sound file is now loaded in the player's RAM, and can be played completely from start to end. Unlike [onClientSoundStream](/wiki/OnClientSoundStream "OnClientSoundStream"), this event only triggers for file streams, not for live ones since live streams never actually end. + +**Source Element:** element +The source of this event is the sound which just finished downloading. + +**Parameters:** + +- `length` (int): The length of the stream in milliseconds + +**Examples:** + +This example would output to the chatbox after the sound is finish that the sound has finished downloading in ... milliseconds. + + +*...and 3 more events in this category* + +--- + + +### Vehicle Events + +*21 events in this category* + +### onClientTrailerAttach + +**Type:** client + +**Description:** This event is triggered by a trailer when it gets attached to a towing vehicle. + +**Source Element:** element +The source of this event is the trailer that is now being towed. + +**Parameters:** + +- `towedBy` (vehicle): the vehicle that is now towing the trailer. + +**Examples:** + +This example shows on chat name of vehicle, what attach a trailer. + +### onClientTrailerDetach + +**Type:** client + +**Description:** This event is triggered when a trailer gets detached from its towing vehicle. + +**Source Element:** element +The source of this event is the trailer that is now detached. + +**Parameters:** + +- `towedBy` (vehicle): the vehicle that was towing the trailer. + +**Examples:** + +This example outputs to the player that's towing the trailer that "The vehicle is now detached". (TESTED!) + +### onClientVehicleCollision + +**Type:** client + +**Description:** This event is triggered when a vehicle collides with an [element](/wiki/Element "Element") or a world object. + +**Source Element:** element +The source of this event is the vehicle that collided with something. + +**Parameters:** + +- `theHitElement` (element): the other entity, or nil if the vehicle collided with the world +- `damageImpulseMag` (float): the impact magnitude (Note: this is NOT the damage it is a force value which is then multiplied by the vehicles collision damage multiplier. for an example of this see below) +- `bodyPart` (int): the bodypart that hit the other element +0: Frame +2: Trunk +3: Hood +4: Rear +5: Front left door +6: Front right door +7: Rear left door +8: Rear right door +13: Front Left tyre +14: Front Right tyre +15: Back Left tyre +16: Back Right tyre +- `collisionX` (float): the X coordinate of the position the collision took place +- `collisionY` (float): the Y coordinate of the position the collision took place +- `collisionZ` (float): the Z coordinate of the position the collision took place +- `normalX` (float): the X coordinate of the surface normal of the hit object +- `normalY` (float): the Y coordinate of the surface normal of the hit object +- `normalZ` (float): the Z coordinate of the surface normal of the hit object +- `hitElementForce` (float): 0 for non vehicles or the force of the other vehicle +- `model` (int): model of the hit element (useful to detect building collisions as hitElement will be nil) + +**Examples:** + + + +*...and 18 more events in this category* + +--- + + +### Weapon Events + +*1 events in this category* + +### onWeaponFire + +**Type:** server + +**Description:** This event is triggered when a custom weapon gets fired. + +**Source Element:** element +The source of this event is the element that fired the weapon. If the server is the creator it returns nil. + +**Examples:** + + +--- + + +### Weapon_creation Events + +*1 events in this category* + +### onClientWeaponFire + +**Type:** client + +**Description:** This event triggers when a [custom weapon](/wiki/Element/Weapon "Element/Weapon") fires a shot. + +**Source Element:** element +The source of this event is the weapon that was fired. + +**Parameters:** + +- `hitElement` (element): the element that was hit +- `posX` (float): the position it will hit +- `posY` (float): the position it will hit +- `posZ` (float): the position it will hit +- `normalX` (float): the normal it hit ( see processLineOfSight ) +- `normalY` (float): the normal it hit ( see processLineOfSight ) +- `normalZ` (float): the normal it hit ( see processLineOfSight ) +- `materialType` (int): the material type it hit ( see processLineOfSight ) +- `lighting` (float): the lighting of the entity it hit ( see processLineOfSight ) +- `pieceHit` (int): the piece of the entity it hit ( see processLineOfSight ) + +**Examples:** + +This example prevents player damage from custom weapons. + +--- + + +## Elements + +Elements are the building blocks of MTA:SA. They represent game objects and entities that can be created, modified, and destroyed. + + +### ACL Elements + +*2 elements in this category* + +### acl + +**Description:** ACL or Access Control List is a set of rights grouped together to create a list, they are defined in the [ACL.xml](/Access_Control_List) file as nodes. These ACLs can then be added to certain [ACL Groups](/aclgroup) to grant or deny these groups specified permissions or acces to server scripting functions defined in the ACL. Example of an ACL: + +```xml + + + + + + + +``` + +This creates ACL called *Example* and gives resources access to start/stop resources and modify other resources but denies access to shutting down the server. Players that are in group using this ACL will be denied access to `shutdown` command. + + +### aclgroup + +**Description:** ACL Groups are groups that holds objects such as accounts, and resources which allows them to do some things depending on the permission the group has/holds. + +#### Default Groups + +MTA has provided some default groups with increasing permissions. These groups are: + +- **Everyone** +- **Moderator** +- **SuperModerator** +- **Admin** +- **Console** - This controls permissions of people who are using the console through `` +- **RPC** - Remote Procedure Call. Specifically grants access to callRemote only and disables commands of default resources. Check the function for details. + +To explain further, I will use the Everyone group as an example. By default it looks like this: + +```xml + + + + + +``` + +You will first notice the acl name inside the group. It defines what permissions the group has. Users and resources in this group will have the permissions specified on the "Default" acl name list. + +**Note**: You will notice this group is special, in that it includes every user and resource by using a **wildcard (\*)** where the user or resource name would be. + +Now, scroll further down the ACL and you will see the `` listing. Note I have trimmed this list dramatically due to its length. + +```xml + + + + + ...etc etc... + + + + ...etc etc... + + + + ...etc etc... + + + + ...etc etc... + +``` + +- `Function` entries are MTA scripting functions. For example, if a resource needed to use restartResource and was only in the 'Everyone' group (with the 'Default' list), it would be denied access to restartResource and fail to work correctly. +- `Commands` are created when a resource uses addCommandHandler. An example would be typing /createvehicle [vehicle] in the chatbox for the freeroam resource. This controls whether users in the group using this ACL can use the command. Note: commands have no effect on resources within the group. Commands are only related to users. +- `General` is a custom right name group created by the admin resource but it works on the same principles. The script works with them by using hasObjectPermissionTo + +You will notice some groups such as admin have multiple `` nodes. An example is the admin group: + +```xml + + + + + + + + + +``` + +This gives all the permissions defined in each node in order of listing. So for example, the admin group makes sure all the permissions are given to admins by using all the lists. If there are any conflicts, the lowest entry wins. For example, pretend these 2 acls were in a group in the following order: + +- `` sets `` +- `` sets `` +- For all users and resources in group admin: `` + +--- + + +### Account Elements + +*1 elements in this category* + +### account + +**Description:** The **account** class represents a [[player]]'s server account. You can get the **account** object associated to any client using [[getPlayerAccount]]. + +Accounts are unique to each client and can be used to store information that is persistent across map changes and user sessions. Clients that join without an account are given a temporary 'guest' account. This can store information like any other account, but isn't saved across sessions. + +When a user logs in or out, the account object assigned to them will change. As such, you must not assume that the account attached to a client remains constant during their session. + +PHP code to check password hashes from the MTA server database is + +
+ Here + This php function will return true if the password matches the hash from the accounts database. + + ```php + function passwordMatch( $plain, $hash ) + { + //-- Empty passwords never match + if ( $plain == "" || $hash == "" ) + return false; + + if ( strlen($hash) == 64 + 32 + 1 ) + { + //-- SHA256 + type + salt + $strSha256 = substr( $hash, 0, 64 ); + $strType = substr( $hash, 64, 1 ); + $strSalt = substr( $hash, 65, 32 ); + + //-- Password hash was generated from MD5, so do the same thing for the test + if ( $strType == "1" ) + $plain = strtoupper(md5($plain)); + + $strPasswordHashed = strtoupper(hash( "sha256", $strSalt . $plain )); + return $strPasswordHashed == $strSha256; + } + else + if ( strlen($hash) == 32 ) + { + //-- MD5 + return strtoupper(md5($plain)) == $hash; + } + return false; + } + ``` + +
+ + +--- + + +### Audio Elements + +*1 elements in this category* + +### sound + +**Description:** The sound element represents a custom sound sent to the client via the use of the file parameter inside the meta file and created either by [playSound](/playSound) or [playSound3D](/playSound3D). + +A sound element can be manipulated in the GTA 3D world via [setElementPosition](/setElementPosition) and [setElementDimension](/setElementDimension). + +Sound elements can also be manipulated using the other [Audio functions](/Scripting_Functions#Audio). + + +--- + + +### Ban Elements + +*1 elements in this category* + +### ban + +**Description:** A **ban** is a pointer that represents a banned player arbitrarily. The following functions allow interaction with a ban. + +--- + + +### Browser Elements + +*1 elements in this category* + +### browser + +**Description:** A **browser** is an element representing a CEF browser instance, created with [createBrowser](/reference/createBrowser/) or [guiCreateBrowser](/reference/guiCreateBrowser/). This element also simultaneously represents the browser’s [texture](/reference/texture/), so it can be used as a texture, e.g. for rendering with [dxDrawImage](/reference/dxDrawImage/). + +--- + + +### DB Elements + +*2 elements in this category* + +### db-connection + +**Description:** The **db-connection** class represents a database connection. + +### db-query + +**Description:** The **db-query** represents a database query returned by the [[dbQuery]] function. It can be used to read the query result with [[dbPoll]], or freed using [[dbFree]]. + +--- + + +### Discord Elements + +*1 elements in this category* + +### discordrpc + +**Description:** The **discordrpc** class represents a static class providing functions for Discord Rich Presence. + +--- + + +### Drawing Elements + +*3 elements in this category* + +### dx-font + +**Description:** The **DX font** class represents a custom typeface which can be used in the [Drawing functions](/Scripting_Functions#Drawing). A DX font is created with [dxCreateFont](/dxCreateFont) and can be used as a parameter in [dxDrawText](/dxDrawText). + +### shader + +**Description:** The shader class represents a Microsoft HLSL Effect File(.fx) loaded by the client, which can be used instead of a texture when calling [dxDrawImage](/dxDrawImage). + + +### texture + +**Description:** The texture class represents a source of renderable pixels which can be used as an image with [dxDrawImage](/dxDrawImage), [dxDrawImageSection](/dxDrawImageSection) or as a value in [dxSetShaderValue](/dxSetShaderValue). + +--- + + +### Engine Elements + +*3 elements in this category* + +### col + +**Description:** The COL class represents a RenderWare Collision File (.col) loaded by the client, which can be imported into a custom model to define its collisions. + +A .col file can contain one or more collision models. Normally, San Andreas assigns each collision model in a file to a geometry model through the model name that is embedded in the collision model. +However in MTA, you can assign any .col file to any model ID; the names are ignored. To prevent loading multiple collision models into one model ID, MTA only loads the first collision model of a .col file and ignores the rest. +Therefore, if you have a .col file containing multiple collision models, you will need to split it into multiple files, with one model per file, and then load and import each of those files using the appropriate scripting functions. +To split a .col file into multiple files, you can use [CollEditor2](http://www.steve-m.com/downloads/tools/colleditor2/). + +Collision data can also be embedded in DFF files. At the moment, vehicle collision replacement works with DFF embedded collisions only. + + +### dff + +**Description:** The DFF class represents a RenderWare Model File (DFF) loaded by the client, which can be used to replace the model associated to a certain model ID. After this has been done, the custom model is applied to all newly created entities from that ID. + +Collision data can also be embedded in DFF files. At the moment, vehicle collision replacement works with DFF embedded collisions only. + + +### txd + +**Description:** The TXD class represents a RenderWare Texture Dictionary (TXD) loaded by the client, which can be imported into a custom model to texture it. + + +--- + + +### Entity Elements + +*17 elements in this category* + +### blip + +**Description:** The blip class represents small icons or blips that can be shown on a player's radar. + +The list of blip icons are available on the [Radar Blips](/radar_blips) page. + + +### building + +**Description:** The building class represents static 3D models in the GTA world. + + +### camera + +**Description:** The camera class represents the local player camera rendering the game to the screen. + + +### colshape + +**Description:** The collision shape class represents invisible collision detection shapes that can be created in the GTA world. Collision shapes are typically used to detect physical entities moving through them and perform actions when they do. + + +### effect + +**Description:** The Effect class represents custom effect elements in the game world such as smoke, sparks, fire etc. + +TODO all effects table + + +### light + +**Description:** The light class represents colored, 3D lights in the GTA world. There are a couple different types of lights, which are point lights, spot lights and dark lights. + + +### marker + +**Description:** The marker class represents colored, 3D shapes in the GTA world. There are several types of markers, including cylinders and checkpoints. In scripts, markers are often used to mark spots and trigger some sort of action when a player goes into them. + + +### object + +**Description:** The object class represents dynamic and static 3D models placed in the GTA world. + + +### ped + +**Description:** The word "ped" is short for "pedestrian" and describes any person in GTA, be it a player or an NPC character. (And even though "pedestrian" doesn't technically apply to people that drive, they still fall under this name) + +The [createPed](/createPed) function specifically creates an NPC, but all other ped functions work on both players and NPC's as they're pretty much the same thing to San Andreas. + + +### pickup + +**Description:** The pickup class represents weapon, health, or armor pickups in the GTA world. Pickups can be picked up by players when they are walked over. Players will not be given health or armor pickups if their health or armor is already full. + + +### player + +**Description:** The player class represents pedestrians controlled by clients. A player element is created when a client connects to the server and destroyed when that client quits. Players cannot be created or destroyed otherwise. + + +### projectile + +**Description:** The projectile class represents the projectiles of certain weapons that are created when the weapon is fired. Alternatively these can be created using [createProjectile](/createProjectile). + + +### radararea + +**Description:** The radar area class represents coloured areas that can be displayed on a player's radar. + + +### searchlight + +**Description:** The searchlight class represents special spotlights in the GTA world. They are different to common spotlights because their visual effects. + + +### vehicle + +**Description:** The vehicle class represents vehicles in the GTA world. Vehicles can be occupied and controlled by players and peds. + + +### water + +**Description:** In San Andreas, the water in the game world (rivers, lakes, seas) is defined through a large number of water polygons, which can be quadrilateral or triangular. + +A water element represents one such polygon. You can create water elements using [createWater](/createWater). + + +### weapon + +**Description:** The Weapon class represents a custom static weapon. Weapon elements created by [createWeapon](/createWeapon) can be manipulated with the following scripting functions. + + +--- + + +### File Elements + +*1 elements in this category* + +### file + +**Description:** The file object refers to a file loaded into memory. +It can be obtained using the [[fileCreate]] or [[fileOpen]] functions and then, for example, read using [[fileRead]] or used for any other file-related operation with the file functions. + +--- + + +### GUI Elements + +*16 elements in this category* + +### gui-button + +**Description:** The **GUI button** class represents GUI buttons in MTA's GUI system. It's only functionality is to detect whether client has clicked it. + +### gui-checkbox + +**Description:** The GUI checkbox class represents GUI checkboxes in MTA's GUI system. These can be checked or unchecked. + +### gui-combobox + +**Description:** The GUI combobox class represents GUI comboboxes in MTA's GUI system. These are drop down lists that can contain large number of items. + +### gui-edit + +**Description:** The GUI edit field class represents GUI edit fields in MTA's GUI system. You can input text in these which you can afterwards check from the script. It can be used, for example when making a registration system. + +### gui-font + +**Description:** The **GUI font** class represents a custom typeface which can be applied to [GUI widgets](/GUI_widgets). A GUI font is created with [guiCreateFont](/guiCreateFont) and can then used as a parameter in [guiSetFont](/guiSetFont). + +### gui-gridlist + +**Description:** The GUI gridlist class represents GUI gridlists in MTA's GUI system. It can be used for example as a selection list or as a list to view information about players (see [old scoreboard resource](/Resource:OldScoreboard)). + + +### gui-label + +**Description:** The GUI label class represents GUI labels in MTA's GUI system. These are simply a bunch of text which client cannot modify. + + +### gui-memo + +**Description:** The GUI memo class represents GUI memos in MTA's GUI system. These are big multiline text fields to what you can type text by default. It is recommended to use [edit fields](/gui-edit) for smaller text inputting. + + +### gui-progressbar + +**Description:** The GUI progress bar class represents GUI progress bars in MTA's GUI system. These are mostly used as loading bars because you can alter the percentage amount of progress in it. + + +### gui-radiobutton + +**Description:** The GUI radio button class represents GUI radio buttons in MTA's GUI system. These can be checked or unchecked and work quite similiar as the GUI checkboxes. + + +### gui-scrollbar + +**Description:** The GUI scrollbar class represents GUI scrollbars in MTA's GUI system. These can be moved with cursor and it's position can be checked and set by script. These are built by default to certain GUI elements ([gridlists](/gui-gridlist)) if they exceed the given size. + + +### gui-scrollpane + +**Description:** Todo + + +### gui-staticimage + +**Description:** The GUI static image class represents GUI static images in MTA's GUI system. These are custom images which can be loaded to clients screen. + + +### gui-tab + +**Description:** The GUI tab class represents GUI tabs in MTA's GUI system. These highly rely on GUI [tab panels](/gui-tabpanel) as they only can be created to them. + + +### gui-tabpanel + +**Description:** The GUI tab panel class represents GUI tab panels in MTA's GUI system. These are just layouts for GUI [tabs](/gui-tab) and highly rely on them. It is recommended to use GUI [windows](/gui-window) if you are not adding tabs to a tab panel. + + +### gui-window + +**Description:** The GUI window class represents GUI windows in MTA's GUI system. These are mainly used as layout for other GUI elements. They can be moved and resized by default. + + +--- + + +### Matrix Elements + +*1 elements in this category* + +### matrix + +**Description:** Matrices are one of the most powerful features of MTA [OOP](/reference/OOP). We did have a presence of Matrices before with [getElementMatrix](/getElementMatrix), but we were given an ugly disgusting table to play with. Now, with the new Matrix class, we can make and magically manipulate Matrices. + + +--- + + +### Resource Elements + +*2 elements in this category* + +### resource + +**Description:** A resource object refers to a resource that is loaded in the server. + +A name, state, root element, base directory path are associated to a resource, among other attributes. + + +### resourceRoot + +**Description:** + +--- + + +### Root Elements + +*1 elements in this category* + +### root + +**Description:** + +--- + + +### Server Elements + +*1 elements in this category* + +### console + +**Description:** The Server Console class represents the server console. + +In the server console you can use many different commands, affecting the players using the server. Please note that only console commands can be used, and that some commands can not be used through the in-game client console, only through the Server Console. + +You can view all latest available server console commands by entering **"help"** into the server console window. + + +--- + + +### Team Elements + +*1 elements in this category* + +### team + +**Description:** The team class represents player teams. Players on the same team can use team features such as teamchat or friendly fire. + +A common misconception is that players would be child elements of team elements. This is wrong. Being part of a team is merely a relational connection rather than a change in element hierarchy. To perform logic on all the players of a team you have to use the [getPlayersInTeam](/getPlayersInTeam) function. + + +--- + + +### Text Elements + +*2 elements in this category* + +### textdisplay + +**Description:** A textdisplay object refers to a "canvas" that can contain many items of text ([textitems](/textitem)). + +Each display can be seen by multiple observers ([players](/player)) and each observer can see multiple displays. For example, you could have a display that showed a score, and a display that showed information specific to one team, such as the location of a flag. Every player would be an observer of the first display and each team would have their own display that its players would be observers of. + +### textitem + +**Description:** A textitem object represents a single area of text, much like a label does in standard GUI programing. + +A text item can only be seen by players if it is added to a [textdisplay](/textdisplay) they are observers of using [textDisplayAddText](/textDisplayAddText). + + +--- + + +### Timer Elements + +*1 elements in this category* + +### timer + +**Description:** A **timer** object refers to a timer set to execute a function a certain number of times with a specified delay. + +Note that after a timer has completed all its iterations, it is destroyed and any stored pointers to it become invalid. Also timers are not under the resource hierarchy, because they are not elements, for instance, if you create a timer, it will not be destroyed when the resource in which it was created is stopped, so in this case you should kill the timer manually. + +--- + + +### Vector Elements + +*3 elements in this category* + +### vector2 + +**Description:** This is a 2D [Vector](/reference/Vector) class. + + +### Vector3 + +**Description:** Represents a 3D [Vector](/reference/Vector). Used for storing and manipulating three-dimensional coordinates (x, y, z). + + +### Vector4 + +**Description:** Represents a 4D [Vector](/reference/Vector). + + +--- + + +### XML Elements + +*1 elements in this category* + +### xmlnode + +**Description:** A xmlnode is an object that represents a node in a XML document tree. + +--- + + +## Quick Reference + +### Most Common Functions + +This section lists some of the most commonly used functions in MTA:SA scripting: + +### getPlayerName + +**Description:** This function returns a string containing the name of the specified player. + +**Parameters:** + +- `thePlayer` (player): the player you want to get the name of + +**Returns:** + +Returns a string containing the requested player's name, or false if the player passed to the function is invalid. +- string: value + +**Examples:** + +Example 2: This example outputs the local player name to the chatbox. + +### setPlayerName + +**Description:** This function changes the specified [player](/wiki/Player "Player")'s name. Note that any change made to a players name with this function is not saved in their settings so the name change only lasts till they disconnect. + +**Parameters:** + +- `thePlayer` (player): the player that will have its name set. +- `newName` (string): the new name to set for the player. + +**Returns:** + +Returns true if the player name was changed succesfully, false if invalid arguments are specified. +- bool: value + +**Examples:** + +Example 1: This example adds a tag before a player's nickname via a /changetag command +Example 2: This example allows you to check if string is valid mta nickname + +### createElement + +**Description:** This function is used to create a new dummy element in the [element tree](/wiki/Element_tree "Element tree") which do not necessarily represent an entity within the San Andreas world. A common use for this function is for creating custom elements, such as a Flag or a Base. + +**Parameters:** + +- `elementType` (string): The type of element being created. +- `elementID` (string): The ID of the element being created. + +**Returns:** + +Returns the element if it was successfully created. Returns false if the arguments are wrong. +- element: value + +**Examples:** + +Example 1: This example creates a "flag" element, named "blue", which will be at the resource's dynamic map. +Example 2: Except for it being placed in a different map root, that line will have the same effect as having this in a .map file: + +### destroyElement + +**Description:** This function destroys an [element](/wiki/Element "Element") and all elements within it in the hierarchy (its children, the children of those children etc). [Player](/wiki/Player "Player") elements cannot be destroyed using this function. A player can only be removed from the hierarchy when they quit or are kicked. The root element also cannot be destroyed, however, passing the root as an argument will wipe all elements from the server, except for the players and clients, which will become direct descendants of the root node, and other elements that cannot be destroyed, such as resource root elements. + +**Parameters:** + +- `elementToDestroy` (element): The element you wish to destroy. + +**Returns:** + +Returns true if the element was destroyed successfully, false if either the element passed to it was invalid or it could not be destroyed for some other reason (for example, clientside destroyElement can't destroy serverside elements). +- bool: value + +**Examples:** + +Example 1: Example 1:This example would destroy every element in the map, with the exception of players and the root element itself. +Example 2: Example 2:This example destroys all vehicles of the specified model: + +### getElementType + +**Description:** This function is used to retrieve the type of an element. + +**Parameters:** + +- `theElement` (element): The element you wish to get the type of. + +**Returns:** + +Returns a string containing the element type, false if invalid arguments were passed. +- string: value + +**Examples:** + +Example 1: This example destroys a haystack when a player targets it + +### createVehicle + +**Description:** This function creates a vehicle at the specified location. + +**Parameters:** + +- `model` (int): The vehicle ID of the vehicle being created. +- `x` (float): A floating point number representing the X coordinate on the map. +- `y` (float): A floating point number representing the Y coordinate on the map. +- `z` (float): A floating point number representing the Z coordinate on the map. +- `rx` (float): A floating point number representing the rotation about the X axis in degrees. +- `ry` (float): A floating point number representing the rotation about the Y axis in degrees. +- `rz` (float): A floating point number representing the rotation about the Z axis in degrees. +- `numberplate` (string): A string that will go on the number plate of the vehicle (max 8 characters). +- `bDirection` (bool): Placeholder boolean which provides backward compatibility with some scripts. It never had any effect, but it is read by the code. It is recommended to ignore this argument, passing false or the variant1 argument in its place. +- `variant1` (int): MISSING_PARAM_DESC +- `variant2` (int): MISSING_PARAM_DESC +- `synced` (bool): MISSING_PARAM_DESC + +**Returns:** + +Returns the vehicle element that was created. Returns false if the arguments are incorrect, or if the vehicle limit of 65535 is exceeded. +- vehicle: value + +**Examples:** + +Example 1: This example creates a 'vehicle spawner' marker that gives the player a vehicle as soon they step into it. +Example 2: This example creates a vehicle five units to the right of a player when they typecreatevehicleand its name in the console: + + + +--- + +## Summary + +This documentation covers the complete MTA:SA Lua scripting API with: + +- **1403 functions** across 52 categories +- **220 events** across 19 categories +- **62 elements** across 21 categories + +Each function, event, and element includes: +- Detailed descriptions +- Parameter information with types +- Return values +- Usage examples +- Related elements and functions + +This API enables developers to create rich, interactive multiplayer experiences in Grand Theft Auto: San Andreas, from simple game modes to complex roleplay servers. + +--- + +## License + +The MTA:SA Lua API and this documentation are provided under the GNU Free Documentation License, Version 1.3. + +--- + +*End of Documentation* diff --git a/MTA_SA_SCRIPTING_DOCUMENTATION.pdf b/MTA_SA_SCRIPTING_DOCUMENTATION.pdf new file mode 100644 index 00000000..5badeef6 Binary files /dev/null and b/MTA_SA_SCRIPTING_DOCUMENTATION.pdf differ diff --git a/MTA_SA_SCRIPTING_DOCUMENTATION_README.md b/MTA_SA_SCRIPTING_DOCUMENTATION_README.md new file mode 100644 index 00000000..15ce94ec --- /dev/null +++ b/MTA_SA_SCRIPTING_DOCUMENTATION_README.md @@ -0,0 +1,118 @@ +# MTA:SA Lua Scripting Documentation for AI + +## English + +### Purpose + +The `MTA_SA_SCRIPTING_DOCUMENTATION.pdf` file is a comprehensive documentation of the Multi Theft Auto: San Andreas Lua scripting API, designed to serve as a knowledge base for Artificial Intelligence systems. + +### Contents + +This 101-page PDF contains: + +- **Complete Lua API Documentation**: All functions, events, and elements for MTA:SA scripting +- **1,403 Functions**: Organized into 52 categories (Player, Vehicle, Element, GUI, etc.) +- **220 Events**: Server and client-side events with parameters and examples +- **62 Elements**: Game objects and entities that can be manipulated +- **Code Examples**: Practical usage examples for functions and events +- **Parameter Details**: Type information and descriptions for all parameters +- **Return Values**: What each function returns and what the values mean + +### Categories Covered + +**Functions:** ACL, Account, Admin, Audio, Blip, Browser, Camera, Colshape, Cursor, Database, Discord, Drawing, Effects, Element, Event, File, GUI, HTTP, Input, Marker, Matrix, Object, Ped, Pickup, Player, Projectile, Radar, Resource, Server, Settings, Sound, SQL, Team, Text, Utility, Vehicle, Water, Weapon, World, XML, and more. + +**Events:** Element, Player, Vehicle, Ped, GUI, Input, Resource, Explosion, Map, Marker, Colshape, Pickup, Server, Client, and more. + +**Elements:** Player, Vehicle, Object, Ped, Marker, Blip, Pickup, Colshape, GUI components, Sound, Browser, and more. + +### Use Cases + +This documentation is ideal for: + +- Training AI models about MTA:SA Lua scripting +- Creating intelligent code assistants and autocomplete systems +- Building automated script generators and validators +- Developing IDE extensions with MTA:SA support +- Understanding the complete MTA:SA API surface +- Learning MTA:SA scripting fundamentals and advanced techniques + +### Files + +- `MTA_SA_SCRIPTING_DOCUMENTATION.md` - Markdown source (178KB) +- `MTA_SA_SCRIPTING_DOCUMENTATION.pdf` - PDF documentation (480KB, 101 pages) + +--- + +## Português (Portuguese) + +### Objetivo + +O arquivo `MTA_SA_SCRIPTING_DOCUMENTATION.pdf` é uma documentação abrangente da API Lua do Multi Theft Auto: San Andreas, projetada para servir como base de conhecimento para sistemas de Inteligência Artificial. + +### Conteúdo + +Este PDF de 101 páginas contém: + +- **Documentação Completa da API Lua**: Todas as funções, eventos e elementos para scripting no MTA:SA +- **1.403 Funções**: Organizadas em 52 categorias (Player, Vehicle, Element, GUI, etc.) +- **220 Eventos**: Eventos server-side e client-side com parâmetros e exemplos +- **62 Elementos**: Objetos e entidades do jogo que podem ser manipulados +- **Exemplos de Código**: Exemplos práticos de uso para funções e eventos +- **Detalhes de Parâmetros**: Informações de tipo e descrições para todos os parâmetros +- **Valores de Retorno**: O que cada função retorna e o significado dos valores + +### Categorias Cobertas + +**Funções:** ACL, Account, Admin, Audio, Blip, Browser, Camera, Colshape, Cursor, Database, Discord, Drawing, Effects, Element, Event, File, GUI, HTTP, Input, Marker, Matrix, Object, Ped, Pickup, Player, Projectile, Radar, Resource, Server, Settings, Sound, SQL, Team, Text, Utility, Vehicle, Water, Weapon, World, XML, e mais. + +**Eventos:** Element, Player, Vehicle, Ped, GUI, Input, Resource, Explosion, Map, Marker, Colshape, Pickup, Server, Client, e mais. + +**Elementos:** Player, Vehicle, Object, Ped, Marker, Blip, Pickup, Colshape, componentes GUI, Sound, Browser, e mais. + +### Casos de Uso + +Esta documentação é ideal para: + +- Treinar modelos de IA sobre scripting Lua no MTA:SA +- Criar assistentes de código inteligentes e sistemas de autocompletar +- Construir geradores e validadores automáticos de scripts +- Desenvolver extensões de IDE com suporte para MTA:SA +- Compreender a superfície completa da API do MTA:SA +- Aprender fundamentos e técnicas avançadas de scripting no MTA:SA + +### Arquivos + +- `MTA_SA_SCRIPTING_DOCUMENTATION.md` - Fonte Markdown (178KB) +- `MTA_SA_SCRIPTING_DOCUMENTATION.pdf` - Documentação PDF (480KB, 101 páginas) + +--- + +## About This Documentation + +This documentation focuses on **scripting for Multi Theft Auto: San Andreas**, not on the wiki repository itself. It extracts and organizes all the scripting API information from the YAML files in this repository to create a comprehensive reference for AI systems and developers. + +The documentation includes: +- Detailed function signatures with parameter types +- Event definitions with all parameters +- Element hierarchies and relationships +- Code examples demonstrating real-world usage +- Return value specifications +- Categorized organization for easy navigation + +--- + +## Generation + +The documentation was automatically generated from the YAML files in this repository using a Python script that: + +1. Parses all YAML files in functions/, events/, and elements/ directories +2. Extracts function signatures, parameters, return values, and examples +3. Organizes content by category +4. Generates comprehensive Markdown documentation +5. Converts to PDF using Pandoc and wkhtmltopdf + +--- + +**Generated on**: 2025-12-08 +**Document Version**: 2.0 (Focused on MTA:SA Scripting API)