Types
This page hosts a list of used data types for scripting.
Types
These types are used in Scripting.
A Sharedtype means that the type is available to be used on both the server and the client in scripting.
SharedClient- client representationClientEffect- effect (FX)SharedElement- elementSharedBlip- blipSharedEntity- entitySharedBuilding- building (GTA Building)SharedPhysical- object that interacts with physicsSharedObject- placeable objectSharedPed- pedestrianSharedPlayer- player
SharedVehicle- any vehicleSharedTrain- train
SharedMarker- markerSharedPickup- pickup
SharedEvent- eventSharedCancellableEvent- cancellable eventSharedKeyEvent- key event
ClientFont- fontClientGUIElement- gui elementClientGUIHtmlElement- gui html elementClientGUIHtmlView- gui html viewClientGUIPage- gui pageClientGUIWindow- gui windowSharedMatrix4x4- matrix of 4 by 4 decimal numbersSharedReflectedFunction- reflected functionSharedResource- resourceClientSoundSharedStreamClientSurfaceClientRenderTarget- client representation - derives fromSurfaceClientTexture- texture - derives fromSurface
SharedTimer- timerSharedVec2- vector of 2 decimal numbersSharedVec3- vector of 3 decimal numbersSharedXmlDocument- xml documentSharedXmlElement- xml element
Types Derived From Element
Types derived from type Element, as shown in the list above.
Blip : Element
Building : Entity : Element
Marker : Element
Object : Physical : Entity : Element
Pickup : Element
Player : Ped : Physical : Entity : Element
Train : Vehicle : Physical : Entity : ElementAbstract Base Types
These types aren't used directly in Scripting. They just represent abstract types used behind the scenes.
Surface- Anything that is drawable (RenderTarget,Texture)
Scripting-Language Types
These scripting-language types are used in the scripting interface.
Scalar types.
bool- Also known asboolean.float-Numberif the scripting language only uses 1 numerical type for ints and floats.function- For callbacks.int-Numberif the scripting language only uses 1 numerical type for ints and floats.null- Also known asnil.object- For elements.Userdataif Lua.stringundefined- Used in JS.
Container types.
array<Type>-Tableif Lua. Keys start at 1 if Lua, otherwise keys start at 0.dictionary<KeyType,ValueType>-Tableif Lua.
Other types.
void- Represents no arguments or no returns.
Handle Existence Span
| Type | Side | Handle Creation | Handle Destruction (With 0 handle references left in scripting too) |
|---|---|---|---|
| Client | Server-Side | When a client is attempting to join the server. OnPlayerJoin. | When a client has begun leaving the server. OnPlayerQuit. |
| Client (Local) | Client-Side | When a client has joined the server, and the local client's client-side has been notified. | n/a |
| Client (Remote) | Client-Side | When a client has joined the server, and the remote clients' client-side have been notified. | When a client has begun leaving the server, and the remote clients' client-side have been notified. |
| Player | Server-Side | When the client's player-ped has spawned. OnPedSpawn. | When the client's player-ped has de-spawned. OnPedWasted. |
| Player (Local) | Client-Side | When the local client's player-ped has spawned. OnPedSpawn. | When the local client's player-ped has de-spawned. OnPedWasted. |
| Player (Remote) | Client-Side | When any of these qualifying conditions occur:
|
When any of these qualifying conditions occur:
|
Please note, a handle that is not properly de-referenced will cause the handle to not be internally destructed.
As a result, this can give the illusion that some functions are broken when they aren't, such as the result of getElementsByType including more than one array entry for the "same element", which are unequal in scripting comparison operators, after internal re-construction, eg. when a client-side player streams out of distance radius of the local player and then streams back in.
To properly de-reference a handle when it's no longer needed, be sure to use delete myVariable; or myVariable = null; in JS, or myVariable = nil in Lua, where applicable.
Continuous attempts of internal destruction of a handle occurs when the qualifying internal destruction reason has occurred, until there are no references remaining in scripting for the handle, rather than only one internal destruction attempt.
A handle becomes invalidated when a handle destruction attempt has first occurred.
Attempting to hold onto a reference of invalidated handles could cause memory exhaustion, and usage of an invalid handle with the scripting API should give a scripting error.
Also, when the local client's player-ped is not spawned, applicable handles will not be usable in client-side scripting.
For example, remote clients' player-ped handles are internally attempted to be destructed when the local client's player-ped de-spawns, until the local client's player-ped re-spawns.
Previous Versions
Type Civilian was removed. All functionality from type Civilianwas moved to type Ped.
Type Transformable was removed. All functionality from type Transformablewas moved to type Element.