- Documentation
- Shared functions
Shared functions
Functions that work on both sides. Use them in server, client and shared scripts.
New functions and events! 6
getNewReturns the blip name set by setBlipName, orBlip Name falsewhen the blip has no name of its own.setNewSets the name of a single blip, shown in the tooltip when you hover it on the ESC map. An empty name (orBlip Name nil) goes back to the icon name from addMapBlipName. At most 64 bytes.getNewReturns the vehicle health floor set by setVehicleHealthFloor (0 = no floor).Vehicle Health Floor getNewReturns the vehicle immunity table set by setVehicleProofs.Vehicle Proofs getNewReturns the vehicle's wheel grip multiplier (the product of every resource's multiplier, 1 = normal).Vehicle Wheel Grip getNewReturns the vehicle's window darkness in percent (0 = normal windows) and, if a colour is set, also its r, g, b components.Vehicle Window Tint
Bitwise operations 12
bitBitwise AND of two or more numbers. Numbers are treated as unsigned 32-bit.And bitArithmetic right shift: keeps the highest bit (the sign of a 32-bit number).Ar Shift bitExtractsExtract countbits starting at positionstart(0 is the lowest bit). The position and length must fit in 32 bits.bitRotates bits left: bits leaving on the left come back on the right.LRotate bitShifts bits left by the given count. Bits pushed beyond 32 are lost.LShift bitBitwise NOT of a 32-bit number.Not bitBitwise OR of two or more numbers.Or bitWritesReplace replaceintocountbits starting atstart, leaving the other bits unchanged.bitRotates bits right: bits leaving on the right come back on the left.RRotate bitLogical right shift (unsigned): zeros come in from the left.RShift bitChecks whether the bitwise AND of all arguments is non-zero, i.e. whether they share a set bit.Test bitBitwise XOR of two or more numbers. Useful for toggling flags.Xor
Blips 28
areChecks whether player icons on the map are turned on.Player Blips Visible createCreates a blip, an icon on the radar and map, at the given point.Blip createCreates a blip attached to an element. The blip moves with it, for example with a vehicle or player.Blip Attached To getReturns the blip's colour.Blip Color getReturns the blip's icon number.Blip Icon getNewReturns the blip name set by setBlipName, orBlip Name falsewhen the blip has no name of its own.getReturns the blip's draw order. Blips with a higher value are drawn on top.Blip Ordering getReturns the blip's size.Blip Size getReturns the range from which the blip shows on the radar.Blip Visible Distance getReturns an icon's name from the map legend.Map Blip Name getReturns the whole map legend: every icon name set by scripts.Map Blip Names getReturns every place label scripts have added to the map.Map Zone Names getReturns the colour of a player's map icon.Player Blip Color getReturns the size of a player's map icon (0-25).Player Blip Size getReturns the player's GPS waypoint, the target they marked on the map or a script set. On the server it is the last point confirmed by the player's game.Player Waypoint isChecks whether a player's map icon is visible.Player Blip Visible removeRemoves the player's GPS waypoint.Player Waypoint setChanges the blip's colour. The colour shows on the plain square (iconBlip Color 0).setChanges the blip's icon.Blip Icon setNewSets the name of a single blip, shown in the tooltip when you hover it on the ESC map. An empty name (orBlip Name nil) goes back to the icon name from addMapBlipName. At most 64 bytes.setSets the blip's draw order. A blip with a higher value covers the others.Blip Ordering setChanges the blip size (the square, iconBlip Size 0).setSets how far away the blip shows on the radar.Blip Visible Distance setChanges the colour of a player's map icon (red by default). On the server everyone sees it, on the client the change is local to that player.Player Blip Color setChanges the size of a player's map icon.Player Blip Size 0hides it.setTurns the icons of all players on the map on or off. They are on by default.Player Blips Visible setShows or hides one player's map icon.Player Blip Visible setSets the game's GPS waypoint for a player: a target on the radar and map, and a road route while in a vehicle. The game confirms it withPlayer Waypoint onPlayerWaypointSet.
Camera 7
fadeFades the screen out or in, in a given colour. Useful for teleports, joining and cutscenes.Camera getReturns the interior the camera is rendered in.Camera Interior getReturns the camera position, the point it looks at, the roll and the field of view.Camera Matrix getReturns the element the camera follows, orCamera Target falsewhen the camera is fixed.setSets the camera interior, i.e. which buildings are drawn around it. Use together withCamera Interior setCameraMatrixto preview interiors.setPlaces the camera at a point and aims it at a target. The camera stops following the player untilCamera Matrix setCameraTarget.setPuts the camera behind the player or makes it follow another element (e.g. when spectating).Camera Target
Chat and console 7
clearClears the chat box. On the server it clears the chat for one player or, with no argument, for everyone.Chat Box isChecks whether the chat box is visible. On the server you pass the player.Chat Visible outputWrites a message in chat. On the server to one player or everyone, on the client in the local player's chat.Chat Box outputPrints a line in the F8 console. On the server, with no target the line goes to every player.Console outputAdds an entry to the debug log (Debug String /debugscript). Levels 1-3 add the script file and line.printPrints text to the chosen console. The first argument is a required category that says where the text goes. The remaining values are converted to text and joined with two spaces.showShows or hides the chat box. On the server you pass a player (orChat rootfor everyone).
Clothes 9
getReturns the clothing part number by name. It accepts English and Polish names, e.g.Clothes Type Id "hat","czapka","trousers","tattoo3".getReturns the name of a clothing part by its number 0-17:Clothes Type Name shirt,head,trousers,shoes,tattoo1-tattoo9,necklace,watch,glasses,hat,extra.getReturns descriptive clothing part names (e.g.Clothes Type Names [0] = "Shirt",[4] = "Tattoos Left upper arm",[16] = "Hats").getReturns every clothing part as a number -> name table (e.g.Clothes Types [16] = "hat").getReturns a ped's tattoos: a slot ->Ped Tattoos { name, texture, place }table (on the server alsoimagefor tattoos fromaddPedTattooImage).getReturns what a player wears on a body part: the texture, the model and the colour. Works on the server and on the client.Player Clothes getReturns the player's whole outfit set by scripts: a part ->Player Clothes All { texture, model, color, name }table.getReturns where on the body tattoo slot 1-9 is (e.g.Tattoo Place Name "lewe ramie"- left upper arm,"plecy"- back,"brzuch"- stomach; the names are in Polish).isChecks whether a clothing part is a tattoo slot (numbers 4-12).Clothes Type Tattoo
Collision shapes 10
createCreates a circle-shaped collision zone on the map - with no height limit (it covers everything above and below the circle).Col Circle createCreates a box-shaped collision zone from the corner (x, y, z): width along X, depth along Y and height upward.Col Cuboid createCreates a collision zone shaped as any polygon on the map (e.g. a gang territory outline). The first two numbers are the centre point (element position), then x, y pairs of vertices - at least three. No height limit by default;Col Polygon setColPolygonHeightsets a range.createCreates a rectangular collision zone from the corner (x, y) - with no height limit. The size is given in metres along X and Y.Col Rectangle createCreates a sphere-shaped collision zone. The zone is invisible; when a player enters or leaves it,Col Sphere onColShapeHit/onColShapeLeavefire (server) oronClientColShapeHit/onClientColShapeLeave(client). A zone can be attached to an element (attachElements) so it moves with it.createCreates a cylinder-shaped collision zone: a circle of radiusCol Tube radiusfrom heightzup byheightmetres.getConverts a colour codeColor From String "#RRGGBB"or"#RRGGBBAA"(the#is optional) or a short"#RGB"/"#RGBA"(with#) into r, g, b, a components. Without an alpha channel it returns a = 255.getReturns the collision zone type. On the client a number: 0 circle, 1 cuboid (alsoCol Shape Type createColBox/createColCube), 2 sphere, 3 rectangle, 4 polygon, 5 tube. On the server a name:"circle","cuboid","sphere","rectangle","polygon","tube".isChecks whether a point (x, y, z) lies inside a zone. It does not need anyone standing in it - it computes the geometry only.Inside Col Shape setLimits a polygon zone vertically: it detects only betweenCol Polygon Height floorandceilheights (e.g. one floor of a building).false, falseremoves the limit. The order of the numbers does not matter.
Elements 54
attachAttaches an element to another. The attached element moves and rotates together with the one it is attached to. An object attached to a vehicle is carried by the game in the same frame as the vehicle physics, so it stays exactly in place even at high speed and in turns.Elements createCreates an element of your own type, e.g.Element "house"or"zone". It sits under the current resource root and disappears when the resource stops. Useful for grouping elements and storing data.destroyDestroys an element together with its children. On the client it also destroys GUI elements.Element detachDetaches an element from the one it was attached to.Elements getReturns the elements attached to an element.Attached Elements getReturns the element's alpha (0 invisible, 255 opaque).Element Alpha getReturns the attached element's offset and rotation relative to the one it is attached to.Element Attached Offsets getReturns the element this one is attached to.Element Attached To getReturns the data of an element attached to a ped's bone.Element Bone Attachment getReturns the offset of an element attached to a bone.Element Bone Position Offset getReturns the rotation of an element attached to a bone (in degrees).Element Bone Rotation Offset getFinds an element by its text ID (from aElement By ID .mapfile orsetElementID).getChecks whether an element has collisions enabled (yes by default).Element Collisions Enabled getReturns an element's data value under a key. Data is set withElement Data setElementData; broadcast data is visible on the client too.getReturns the element's dimension. Elements in different dimensions cannot see each other.Element Dimension getReturns an element's health: peds 0-100 (up to 176 with full stamina), vehicles 0-1000 (below 250 it burns).Element Health getReturns the element's text ID.Element ID getReturns the element's interior number (0 is the outside world).Element Interior getReturns the element's matrix (position and rotation). By default a 4x4 table; withElement Matrix legacy = falseaMatrixobject.getReturns the element's model. For a playerElement Model -1means CJ in the outfit chosen in the launcher, and0plain CJ.getReturns an element's position in the world: a player, vehicle, object or marker.Element Position getReturns the element's bounding radius (the default for its type when not set).Element Radius getReturns the element's rotation in degrees.Element Rotation getReturns all elements of a type, optionally only under a given element (e.g.Elements By Type resourceRoot).getReturns the elements inside a collision shape, optionally of one type only.Elements Within Col Shape getReturns the elements that are inside a marker right now: players, vehicles, peds, objects, pickups and other markers. AElements Within Marker checkpointmarker is a circle with no height limit, the other types are a sphere with a radius equal to the marker size. The result can be limited to one type.getReturns elements within a radius of a point, optionally only of a given type and dimension.Elements Within Range getReturns the element type, e.g.Element Type "player","vehicle","ped","object". GUI elements have types prefixed with"gui-".getReturns the element's velocity. Units: 1 is 50 m/s, so km/h is the vector length times 180.Element Velocity hasChecks whether an element has a value under a key. UnlikeElement Data getElementData, it tells a missing value apart fromfalse.isChecks whether a value is an existing element. Use it before acting on an element that may have been destroyed.Element isChecks whether an element is attached to another.Element Attached isChecks whether an element is attached to a ped's bone.Element Attached To Bone isChecks whether an element is frozen (does not move).Element Frozen isChecks whether an element is in water.Element In Water isChecks whether an element is currently inside a collision shape.Element Within Col Shape isChecks whether an element is inside a marker.Element Within Marker removeRemoves an element data value under a key (for all players).Element Data setSets an element's alpha (0 invisible, 255 opaque). Works on players, peds, objects and vehicles (a vehicle together with its wheels).Element Alpha setChanges the offset and rotation of an attached element.Element Attached Offsets setChanges the offset of an element attached to a bone, without re-attaching it. The element moves relative to the bone right away.Element Bone Position Offset setChanges the rotation of an element attached to a bone, without re-attaching it.Element Bone Rotation Offset setTurns an element's collisions on or off.Element Collisions Enabled setStores a value under a key on an element. By default the value is sent to all players, which firesElement Data onElementDataChange.setMoves an element to another dimension. Elements in different dimensions cannot see each other.Element Dimension setFreezes or unfreezes an element. A frozen element does not move.Element Frozen setSets an element's health.Element Health 0kills a player or ped and firesonPlayerWasted/onPedWasted.setSets an element's text ID.Element ID setMoves an element to an interior. A player in an interior only sees buildings and elements with the same number.Element Interior setSets the element's position and rotation from a matrix (a 4x4 table or aElement Matrix Matrixobject).setChanges the element's model. For players and peds you can also pass the clothing and skin variant (0-3); without them the server picks one so everyone sees the same.Element Model setMoves an element to the given place. On the server it works for any element. On the client it moves your own character (up to 50 m it is a plain move in the same frame andElement Position getElementPositionreturns the new place right away, so it can be called every frame, e.g. for noclip; farther it is a teleport that loads the area), as well as client objects, sounds and collision shapes. An object moved every frame inonClientPreRenderis drawn in its new place in the same frame.setSets the element's rotation in degrees. On the client it turns your own character in the same frame (no teleport) and client objects.Element Rotation setSets the element's velocity (1 is 50 m/s). On the client it works for your own character and vehicle; on the ground the ped's animation cancels horizontal movement, vertical always works.Element Velocity
Events 10
addRegisters a custom event with the given name so it can be triggered (Event triggerEvent,triggerClientEvent,triggerServerEvent) and handled (addEventHandler). WithallowRemoteTrigger = truethe event can come from the other side of the network: on the server - from a client viatriggerServerEvent, on the client - from the server viatriggerClientEvent. Without it, events from the network are rejected, which protects the server from clients faking events.addAttaches a function to an event. This is how you react to a player joining, dying, a key press, every frame and your own events.Event Handler cancelCancels the current event from inside its handler. For events that allow it, it blocks the default action, e.g.Event onPlayerChat(the message will not appear in chat),onPickupHit(the pickup will not be collected),onVehicleStartEnter(the player will not get in). Other handlers still run and can check the state withwasEventCancelled. On the server you can give a reason, readable withgetCancelReason.getReturns the total number of functions attached to an event on all elements. Useful for finding leaks (e.g. someone addingEvent Handler Count onClientRenderevery second).getReturns the list of functions attached to an event directly on the given element (without handlers on parents).Event Handlers getReturns a sorted list of the names of all known events: built-in ones and those registered withEvent Names addEvent.isChecks whether an event with this name exists (built in or added withEvent Added addEvent).removeDetaches a function from an event. You must pass the same name, element and the same function (the same variable) as inEvent Handler addEventHandler- an anonymous function written again is a different function.triggerTriggers an event on an element on the same side (server → server, client → client). The handlers run immediately, before the function returns. The event must be registered withEvent addEventor be built in.wasChecks whether the current event was cancelled withEvent Cancelled cancelEventin an earlier handler; outside an event - whether the last event was cancelled.
Files 16
fileCloses a file and writes its buffer to disk. The handle becomes invalid.Close fileCopies a file to a new path. An existing target file is overwritten only withCopy overwrite = true.fileCreates a new file or empties an existing one and opens it for writing. On the client the files go to a private folder for that server on the player's computer (limit 64 MB per file and 256 MB per server).Create fileDeletes a file. The file must not be open at the time.Delete fileChecks whether a file with this path exists.Exists fileWrites buffered file data to disk without closing it. Useful for logs that must survive a crash.Flush fileReads a whole file in one call. Accepts a file handle or a path (it then opens and closes the file itself).Get Contents fileReturns the path of an open file (as given when opening it).Get Path fileReturns the current position in the file (bytes from the start).Get Pos fileReturns the file size in bytes.Get Size fileChecks whether the file position has reached the end.Is EOF fileOpens an existing file for reading and writing (or read-only). On the server the path is relative to the resource folder and cannot leave it. On the client it first looks for the script's own files (written withOpen fileCreate), then for<file>files sent by the server - those are read-only;":other/file"points to another resource's file. Close the file withfileClosewhen done.fileReads the given number of bytes from the current position and moves the position. At the end of the file it returns an empty string. Binary data is returned unchanged.Read fileRenames a file or moves it within the resource folder.Rename fileSets the file position for the next read or write (e.g.Set Pos fileGetSize= append at the end).fileWrites strings from the current position (each argument one after another) and moves the position. Supports binary data.Write
Fire 2
createStarts a fire. On the server every player sees it, including players who join later, and the function returns the fire's number. On the client the fire burns only in that one game.Fire extinguishPuts out fire. On the server it does so for everyone: by fire number, all fires within a radius of a point, or all at once (no arguments). On the client it only puts out locally started fires.Fire
Game engine 5
engineFrees a model fromFree Model engineRequestModel. On the server the model is shared: objects, cars and peds using it get the parent model; on the client it frees the local model. A named model keeps its number inmodel-ids.jsonunlessforgetName=true.engineReturns a model number by name. On the server it finds new named models (Get Model IDFrom Name engineRequestModel) and vehicles; on the client also game models by name.engineReturns a model name by number: of a new named model or of a vehicle.Get Model Name From ID engineReturns the parent model of a model fromGet Model Parent engineRequestModel(falseif it is not such a model).engineCreates a new model under a new number, shared by every player (also those who join later). An object (Request Model "object"/"timed-object", parent 1337 by default) gets a number from the 18631-19999 pool and is a copy of the parent;engineReplaceModelandengineReplaceCOLgive it a look and a collision. A vehicle ("vehicle", parent 400), a ped ("ped", parent 7) and a tuning part ("upgrade", parent 1000-1193) get a number 20000-29999 and behave like the parent (seats, sound, handling, tuning), whileengineReplaceModelin a client script gives the look. The third argument is a specific number or a name: the same name always gives the same number (stored in the server'smodel-ids.json), so cars and objects from a database are still that model after a restart, and a named model stays when the resource stops. On the client, the name of a server model returns its shared number. A model requested on the client before the game has loaded its models gets its number at once and is created once loading finishes.
Input and controls 14
addRegisters a chat and console command (e.g.Command Handler /car). When a player types it, the function is called. On the server the function gets the player, the command name and the following words as separate arguments; on the client the command name and the words. One command can have several functions, also from different resources. The command goes away with the resource that added it.bindBinds a function or a command to a player's key. The function gets (on the server also the player) the key name, the state and the extra arguments fromKey bindKey. Instead of a function you can pass a command name: the key runs it like/command. On the server the player's game watches the key and reports presses to the server.executeRuns a command registered withCommand Handler addCommandHandleras if a player typed it. On the server you pass a player (ornil) and the arguments: a single string is split into words like in chat. On the client it runs client commands.getTells whether a control belongs to walking (Control Group "foot") or to a vehicle ("vehicle").getReturns the game control names accepted byControl Names toggleControl,setControlStateandisControlEnabled.getReturns the functions (and command names) bound to a key.Functions Bound To Key getReturns the first key a function is bound to.Key Bound To Function isChecks whether a game control is enabled (not blocked withControl Enabled toggleControlortoggleAllControls).isChecks whether a function is bound to a key (a specific one or any).Key Bound isChecks whether a control name is known to the game.Valid Control Name removeRemoves a command added withCommand Handler addCommandHandler. With a function it removes only that handler; without one it removes every handler of the command.toggleEnables or disables all game controls at once (e.g. during a cutscene or when freezing a player). Chat, console andAll Controls bindKeykeys keep working.toggleEnables or disables one game control, e.g. shooting (Control fire), jumping (jump) or entering vehicles (enter_exit). A disabled control ignores the player's keys. On the server you pass a player orroot.unbindUnbinds a function or a command from a key. Without a function it removes everything from the key in that state, and without a state in both states.Key
Lights 4
getReturns the point the searchlight shines at.Search Light End Position getReturns the radius of the light spot at the beam's end (10 by default).Search Light End Radius getReturns the point the searchlight shines from.Search Light Start Position getReturns the beam radius at the source (1 by default).Search Light Start Radius
Markers 8
createCreates a marker in the world: a coloured cylinder to step into (e.g. a job entrance), an arrow above a spot, a corona or a ring. When a player enters it, the server firesMarker onMarkerHitwith the player as the first argument, andonMarkerLeaveon exit. Types:"cylinder","checkpoint","arrow","corona"(a soft ball of light facing the camera),"ring". The size is the diameter in metres.getReturns a marker's colour.Marker Color getReturns the number of all markers on the server.Marker Count getReturns a marker's size (diameter in metres).Marker Size getReturns the marker type (Marker Type "cylinder","checkpoint","arrow","corona","ring").setChanges a marker's colour and alpha, e.g. green when a job is available and red when it is not.Marker Color setChanges a marker's size (diameter in metres). The entry zone (Marker Size onMarkerHit) changes along with it.setChanges a marker's type without recreating it (e.g. a cylinder becomes an arrow).Marker Type
Math, vectors and matrices 7
getReturns the shortest difference between two angles in degrees, in the range -180 to 180. Positive when you need to turn towards the increasing angle.Angle Difference getConverts a heading (like the Z rotation in GTA) and pitch in degrees into a unit direction vector.Direction From Rotation getReturns a point at the given distance fromPoint From Distance Rotation (x, y)in the given direction. Angles as in GTA: 0 is north and they grow counter-clockwise.interpolateComputes an angle between two angles, going the shorter way. The result is in the 0-360 range.Angle isChecks whether a value is a matrix (aMatrix Matrixobject).isChecks whether a value is a vector (Vector Vector2,Vector3orVector4).math.clampClamps a number to the range fromlotohi.
Miscellaneous 53
attachAttaches an element (e.g. an object) to a ped's bone, with an offset and rotation. The element moves with the bone, e.g. a hat with the head or a weapon in a hand. Bone numbers are the same as inElement To Bone getBoneIDs(e.g. 1 pelvis, 8 head, 25 right hand, 35 left hand).base64Decodes base64 text back into data.Decode base64Encodes text or binary data in base64 (e.g. an image to send as text).Encode createCreates an explosion at a spot. On the server every player sees it and it hurts like in the game; on the client the explosion is only in that game (it triggersExplosion onClientExplosion, which can cancel it). Types 0-12: 0 grenade, 1 molotov, 2 rocket, 3 weak rocket, 4 car, 5 quick car explosion, 6 boat, 7 helicopter, 8 mine, 9 object, 10 tank shell, 11 small, 12 tiny.decodeDecrypts, decodes or unpacks data fromString encodeString, also data made on another server. Withaes128you pass the key and theiv, withrsathe private key; withzlibthe format can be left out: gzip, zlib and raw are recognised by their header. Characters outside thebase64andbase32alphabets are skipped. Works on the server and on the client.detachDetaches an element attached to a bone withElement From Bone attachElementToBone. The element goes back to its own position (the one fromsetElementPosition), so if it should stay where the hand was, set its position before detaching.encodeEncrypts, encodes or compresses text. Works on the server and on the client. Algorithms:String tea(raw TEA bytes, no base64),aes128(the key must be exactly 16 characters; it also returns a randomivneeded to decrypt),rsa(a public key fromgenerateKeyPair),base64(varianturl),base32(the Crypto++ alphabet, varianthex= RFC 4648 base32hex),zlib(formatgzip,zliborraw, level 0-9, strategy). Withbase64,base32andzlibthe options table can be left out. With a callback the result goes to it in the next frame and the function returnstrue.fromReads JSON text and returns a Lua value. A top-level array (the wayJSON toJSONwrites) unpacks into several results. Broken JSON givesniland a warning with the error position.generateCreates an RSA key pair: private (PKCS#8) and public (X.509), both as binary DER data. To store them in a file or a database turn them into text, e.g. withKey Pair base64Encode.encodeString/decodeStringalso accept PEM keys. Size 512-8192 bits (default 2048; on the client a multiple of 64). With a callback the keys go to it.getReturns the height stored withAircraft Max Height setAircraftMaxHeight(800 by default).getReturns the speed stored withAircraft Max Velocity setAircraftMaxVelocity(1.5 by default).getReturns all of an element's data set withAll Element Data setElementDataas a key -> value table.getReturns the English name of a body part by its damage number (3-9):Body Part Name Torso,Ass,Left Arm,Right Arm,Left Leg,Right Leg,Head.getReturns the setting fromClouds Enabled setCloudsEnabled(trueby default).getComputes the distance between two points on a plane (without height).Distance Between Points2 D getComputes the distance between two points in space.Distance Between Points3 D getReturns the value of an easing curve for progress 0-1:Easing Value Linear,InQuad,OutQuad,InOutQuad,OutInQuad,InElastic,OutElastic,InOutElastic,OutInElastic,InBack,OutBack,InOutBack,OutInBack,InBounce,OutBounce,InOutBounce,OutInBounce,SineCurve,CosineCurve. Useful for smooth interface animations.getReturns the draw distance stored withFar Clip Distance setFarClipDistance(800 by default).getReturns the fog distance stored withFog Distance setFogDistance(100 by default).getReturns the limit stored withFPSLimit setFPSLimit(36 by default).getReturns the game speed set withGame Speed setGameSpeed(1 by default).getReturns the setting fromInterior Sounds Enabled setInteriorSoundsEnabled(trueby default).getReturns the height stored withJetpack Max Height setJetpackMaxHeight(100 by default).getReturns the game clock minute length in milliseconds.Minute Duration getReturns the moon size stored withMoon Size setMoonSize(3 by default).getReturns the setting fromOcclusions Enabled setOcclusionsEnabled(trueby default).getReturns the rain level stored withRain Level setRainLevel(0 by default). Works on the server and the client.getReturns the real date and time of the server (or the player's computer) as a table:Real Time second,minute,hour,monthday,month(0-11),year(years since 1900),weekday(0 = Sunday),yearday,isdstandtimestamp. With an argument it breaks down the given timestamp.getReturns the root of the element tree: every server element is its child. The same as theRoot Element rootvariable. Events attached to it come from every element.getReturns the number of milliseconds since start (a clock that does not go back when the system time changes). For measuring intervals, subtract two values.Tick Count gettokReturns one part of the text (counted from 1), split the same way as insplit.hashComputes the hash of text with a chosen algorithm:md5,sha1,sha224,sha256,sha384orsha512. The result is hexadecimal.inspectTurns any value into readable text: tables are expanded, cycles are detected and elements are shown aselement:type[id]. Useful when hunting bugs.interpolateSmoothly moves from one set of three numbers to another (e.g. a position or a colour) by progress 0-1 and a curve like inBetween getEasingValue. It also accepts twoVector3vectors.iprintPrints values throughinspectto the debug console. Several arguments are separated with spaces.isChecks whether the cursor is shown. On the client: by any resource. On the server: whether the server showed it to the player withCursor Showing showCursor.isChecks whether the ESC map is available (the server sets it).Map Enabled isChecks whether slow motion of a kind is on (Slow Motion Enabled "all"= both).md5Computes the MD5 hash of text (32 hex characters, upper case). Do not use it for passwords; usepasswordHashfor them.resetRestores the default draw distance (800).Far Clip Distance restoreRestores every building and world object hidden withAll World Models removeWorldModel. On the server it affects every player, on the client only what this client hid.setSets the world draw distance. For compatibility with existing scripts the value is stored and returned byFar Clip Distance getFarClipDistance, but Trilogy Hub does not change the in-game distance yet.setSets how many milliseconds one game clock minute lasts (1000 by default, so a game day lasts 24 minutes). A higher value = a slower day.Minute Duration setTurns the game's occlusion zones on or off. In Trilogy Hub what is hidden is computed by Unreal Engine, so the value is only stored (Occlusions Enabled getOcclusionsEnabled) so that existing scripts run without errors.setTurns the game's slow motion on or off: at the weapon wheel (Slow Motion Enabled "wheel") and during stunt jumps ("stunt"). Both are off by default, because in multiplayer slowing down one player breaks the game. On the server the setting applies to every player, on the client only to that game.sha256Computes the SHA-256 hash of text (64 hex characters, upper case).showShows or hides the mouse cursor. The cursor stays visible while at least one resource wants it, so hiding it in one resource does not close another's cursor. By default, while the cursor is shown, the ped controls are blocked.Cursor splitSplits text into parts by a separator and returns a table. The separator is a string (each of its characters splits the text) or a character code, e.g.32for a space. Empty parts are skipped.teaDecrypts text fromDecode teaEncode(also from other servers) with the same key. A wrong key gives no error, just different bytes.teaEncrypts text with the TEA cipher and returns base64, compatible with the standard TEA used by existing scripts, so previously encrypted text can be read here. Only the first 16 bytes of the key count. TEA is not a strong cipher; useEncode encodeStringwithaes128for serious data.tocolorPacks a colour from four components into one ARGB number used by thedxfunctions.toTurns a Lua value (a number, a string, a table, an element) into JSON text, e.g. to store in a file, a database or account data. The format is the same: the result is always a JSON array, and elements are written so thatJSON fromJSONcan read them back. A table that appears a second time (including a table that contains itself) is written as a"^T^n"reference, andfromJSONrestores it as the same table.utf8Another name forLen utfLen: counts the characters in UTF-8 text (accented letters count as one character, not two bytes).
Objects 10
createCreates an object from a San Andreas model (e.g. 1337 bin, 3095 ramp, 1225 explosive barrel) or a model replaced withObject engineReplaceModel. Everyone in the same interior and dimension sees it; it stays in place and has collision. WithisBreakable = truethe game treats it as breakable and it can be smashed.getReturns San Andreas map objects (hydrants, barrels, boxes, lamp posts…) that players moved or damaged. On the server each entry has a key shared by all players, model, position, rotation (quaternion), health, a broken flag and the player who last moved it. On the client it returns map objects loaded in this game with aMap Objects movedfield.getReturns an object's scale on three axes (1, 1, 1 by default).Object Scale isReturns whether map object synchronisation is on.Map Object Sync Enabled isReturns whether the object can be broken (Object Breakable breakObject).trueby default unless changed withsetObjectBreakable.isChecks whether an object is currently being moved byObject Moving moveObject.moveSmoothly moves an object to a new place over the given time, optionally rotating it by the given angles (relative to its current rotation) and with the chosen easing. Everyone sees the movement; when it ends the object stays in the new place. Used for gates, lifts, platforms. Easing:Object "Linear","InQuad","OutQuad","InOutQuad","OutInQuad","SineCurve","CosineCurve".setSets whether the object can be broken withObject Breakable breakObject.setChanges an object's size (1 = normal, 2 = twice as big). The game applies one scale to all axes - the first number counts.Object Scale stopStops a movement started withObject moveObject; the object stays where it was at that moment.
Particles 10
burstReleases the given number of particles at once, regardless ofParticles rate: an explosion, a hit, a burst of confetti.createA short effect: the emitter releases particles for the given time and removes itself once the last one fades. No need to destroy it. On the server, every player nearby sees the effect.Particle Effect createCreates an emitter of moving particles simulated by the game: fire, smoke, sparks, snow, portals and anything you build from the settings. The fourth argument is a preset name or a settings table, the fifth overrides chosen fields of the preset. Returns aParticle Emitter "particle"element that can be moved, attached and destroyed like any other. Called on the server, it creates an emitter every player sees.getReturns a copy of the emitter's settings. You can change it and pass it back toParticle Emitter Settings setParticleEmitterSettings.getReturns the ready-made particle effects as aParticle Presets { name = description }table.getReturns a copy of a preset's full settings, as a starting point for your own.Particle Preset Settings getReturns the names of the built-in particle shapes (theParticle Sprites spritefield).isChecks whether the emitter releases new particles.Particle Emitter Enabled setStarts or pauses releasing new particles. A disabled emitter lets the particles already released live out their life; enabling it again restarts theParticle Emitter Enabled durationtime.setChanges chosen settings of a running emitter (the same fields as inParticle Emitter Settings createParticleEmitter), the rest stays. Living particles pick up the new colour and size immediately.
Peds 29
createCreates a new NPC ped on the server (a pedestrian driven by the game, not by a player) and shows it right away to every player nearby. The ped gets 100 health, a random appearance variant (clothes and skin tone, seePed setPedVariant) and belongs to the resource that created it, so it disappears together with that resource onstop. Optionally it can be made aggressive straight away or told to attack a chosen target.getReturns the number of rounds in the weapon's current clip, i.e. how many shots are left before reloading. Without a slot it refers to the weapon in hand; with a slot, to the weapon in that inventory slot. On the client it always refers to the weapon in hand.Ped Ammo In Clip getReturns the block and name of the animation a ped is playing (set withPed Animation setPedAnimation). On the client, for peds in this game, it also returns the progress (0-1) and speed of an IFP animation. Returnsfalsewhen the ped is not playing any animation.getReturns a ped's armour (body vest) on a 0-100 scale. Armour absorbs damage before health, so a ped with full armour survives roughly twice as many shots. On the server the value comes from the last state sent by the player's game; on the client it is read straight from the game.Ped Armor getReturns the world position of a chosen skeleton bone of a ped, such as the head or a hand. On the client the position is exact and follows the animation (the bone is read from the game). The server does not know the ped's pose, so it returns an approximation: a fixed bone offset of a standing ped, rotated to match its heading. Bone numbers are the ones fromPed Bone Position getBoneIDs(e.g. 8 head, 25 right hand, 35 left hand); on the client a game bone index also works.getReturns the element an NPC keeps looking at (set withPed Focus setPedFocus) and whether it turns its head too. On the client it returns the local setting first, and the server's one when there is none. Returnsfalsewhen the NPC is not focused on anything.getReturns the vehicle a ped is sitting in (as the driver or a passenger). When the ped is on foot it returnsPed Occupied Vehicle false. It is the simplest way to find out what a player is driving, e.g. to repair or recolour their car.getReturns the seat number a ped occupies: 0 is the driver, 1 the front passenger, 2 and 3 the rear seats (buses and trains also use higher numbers). When the ped is on foot it returnsPed Occupied Vehicle Seat false. Useful when a command should work only for the driver.getReturns a San Andreas stat value for a ped, e.g. weapon skill, stamina, muscle or driving skill. Stats range from 0 to 1000 and affect gameplay (e.g. 69-79 are weapon skills; at 999 a ped dual-wields pistols). On the client, for your own ped the value is read from the game, for others from the server.Ped Stat getReturns all ammo for a weapon (clip plus reserve). Without a slot it refers to the weapon in hand; with a slot, to the weapon in that inventory slot. On the client it always refers to the weapon in hand.Ped Total Ammo getReturns the ID of the weapon a ped is holding (0 = fists), or of the weapon in the given inventory slot. Slots are weapon groups: 0 fists, 1 melee, 2 handguns, 3 shotguns, 4 sub-machine guns, 5 assault rifles, 6 rifles, 7 heavy weapons, 8 grenades, 9 sprays and extinguishers, 10 gifts, 11 goggles and parachute, 12 detonator. On the client it returns only the weapon in hand.Ped Weapon getReturns a list of every valid ped model number, i.e. the skins you can pass toValid Ped Models createPed,setElementModelorspawnPlayer. Numbers with no ped behind them in the game are left out. By default it also includes new ped models added by script withengineRequestModel. Useful for picking a random skin or building a character selection menu.isChecks whether a player or an NPC is damage proof (Ped Damage Proof setPedDamageProof).isChecks whether a player or an NPC is dead, i.e. has zero health or is lying dead waiting to respawn. On the server it uses the state reported by the player's game; on the client it uses the health seen in this game. A dead player comes back only throughPed Dead spawnPlayer.isReturns the value set withPed Doing Gang Driveby setPedDoingGangDriveby.falseby default.isChecks whether a ped is crouching (the crouch key). On the server the state comes from the player's game; on the client straight from the game. A crouching ped is a smaller target and moves slower.Ped Ducked isChecks whether a ped is sitting in any vehicle (in any seat). It also returnsPed In Vehicle falsewhile the ped is still getting in, before it takes the seat. When you need the vehicle itself, usegetPedOccupiedVehicle.isChecks whether a ped is on fire. On the server it returnsPed On Fire truewhen a script set it withsetPedOnFireor when the player's game reports they are really burning (e.g. they walked into fire or got hit by a flamethrower). On the client it reads the state straight from the game.isChecks whether a player is wearing a jetpack. The state comes from the player's game; for 2 seconds afterPed Wearing Jetpack setPedWearingJetpackthe server returns the value it has just set, before the game confirms the change.isChecks whether a model number is a real ped model that can be used inValid Ped Model createPed,setElementModelorspawnPlayer. It accepts the game's models (0-311 except empty numbers) and new peds added withengineRequestModel. Call it before applying a skin a player typed into a command.reloadMakes a ped reload the weapon it is holding, as if the reload key was pressed. On the server the order goes to the player's game; for an NPC it is stored as a reload request. On the client it only works for the local player.Ped Weapon setPlays an animation on a ped. The animation comes from a game animation block (e.g.Ped Animation ped,dancing,smoking) or from an IFP file loaded withengineLoadIFP. Calling it without a block stops the animation. On the server the animation reaches every player. On the client it only runs in this game: for the local player others see it through pose streaming; for a remote player the function returnsfalsebecause their appearance comes from their own game.setSeeks a ped's current animation to a chosen point (0 = start, 1 = end). On the server it applies to the animation set by the server'sPed Animation Progress setPedAnimationand reaches every player. On the client it applies to an IFP file animation playing on a ped in this game, and the animation name must match the current one.setChanges the playback speed of a ped's current animation: 1 = normal, 0.5 = half speed, 0 = paused. On the server it applies to the animation from the server'sPed Animation Speed setPedAnimation; on the client to an IFP file animation on a ped in this game.setMakes a player or an NPC damage proof (or removes it). A player takes no damage from other players (shots, hits, a knife from behind) or from the game (falls, fire, explosions, cars); game damage is undone and health comes back on the player at once. An NPC takes no damage in any game, and the server rejects hits on it. Everyone sees the state (Ped Damage Proof isPedDamageProofon both sides). On the client side it works only on NPCs and only for this player.setTells a ped to get into a vehicle the normal way, walking up and playing the door animation. On the client it only works for the local player: the player walks to a vehicle within 10 m and gets in (other peds givePed Enter Vehicle false). On the server it records the ped's task and sends every client theonClientPedEnterRequestevent (ped, vehicle, seat), which a client script can handle; the ped itself does not walk up yet on the server.setMakes an NPC keep looking at a chosen element: the ped turns its whole body toward it, optionally its head too, and follows it as it moves. On the server everyone sees it. On the client it only works in this game and overrides the server's setting;Ped Focus nilbrings back what the server set. Useful for shopkeepers, guards and NPCs in cutscenes.setSets a ped on fire or puts it out. A player really starts burning in their game: the fire is visible and they lose health until the fire goes out by itself or untilPed On Fire setPedOnFire(player, false). For NPCs the value is stored for scripts.isPedOnFirefor a player shows whether their ped is really burning.setGives a player a jetpack or takes it away. The order goes straight to the player's game, so they can take off immediately. Works only for players (not NPCs); a jetpack cannot be put on while the player is in a vehicle.Ped Wearing Jetpack
Pickups 5
createCreates a pickup: a spinning item to collect - a health pack, body armour, a weapon or any model (e.g. a building entrance icon). A player collects it by walking into it; the server then firesPickup onPickupHit(cancelEvent()there stops the collection), and the pickup hides forrespawnIntervaland comes back. The meaning ofamountdepends on the type: health or armour to add, a weapon ID, or a model ID.getReturns the amount of ammo in a weapon pickup.Pickup Ammo getReturns the health or armour points given by a type 0 or 1 pickup.Pickup Amount getReturns the pickup type: 0 health, 1 armour, 2 weapon, 3 custom model.Pickup Type getReturns the weapon ID of a type 2 pickup.Pickup Weapon
Players 19
getReturns the player whose computer runs the script. TheLocal Player localPlayervariable gives the same. On the server it returnsfalse.getFinds a player by nickname. On the client letter case does not matter.Player From Name getReturns the player's money. The server holds the balance; the in-game counter only displays it.Player Money getReturns the player's nickname.Player Name getReturns the nametag text (the nickname by default).Player Nametag Text getReturns the player's ping in milliseconds.Player Ping getReturns all players. The same asPlayers getElementsByType("player").getReturns the player's wanted level (0-6 stars). Only the server gives stars; the game never does on its own.Player Wanted Level getReturns all of the server's voice chat settings as a table. Keys:Voice Settings enabled,mode("proximity"– heard nearby,"global"– everyone hears everyone,"channels"– nearby plus channels),range(range in metres, 3–250, default 40),minDistance(up to this distance the voice has full volume, default 2),falloff(volume drop with distance:"linear","inverse","exponential"),wallDamping(damping through walls 0–1, default 0.75),pushToTalk,pushToTalkKey(default talk key,"z"),bitrate(quality in kb/s, 8–64, default 32),occlusion,reverb,vehicleMuffle(muffled inside a closed car),indicator(icon above the speaker) andmutedByDefault(new players are muted). The client gets the same table as the server.isChecks whether the game's hints and tutorials are enabled for a player (Player Help Texts Enabled setPlayerHelpTextsEnabled). On the client it checks the local player.isChecks whether a game HUD component is visible for the player (according toPlayer Hud Component Visible setPlayerHudComponentVisible). A component with no setting of its own follows"all".isChecks whether the player's nametag is shown.Player Nametag Showing isChecks whether a player is talking through voice chat right now. On the client, for the local player it means their microphone is transmitting.Player Talking isChecks whether a player is muted in voice chat: byPlayer Voice Muted setPlayerVoiceMutedor, if that function was not used, by the server settingmutedByDefault. Also works on the client.isChecks whether the player sees the game's WASTED screen after death.Player Wasted Screen Enabled isChecks whether voice chat is enabled on the server.Voice Enabled setTurns the game's hints and tutorials on or off (the San Andreas help box, e.g. the first time you pull a driver out of a car). They are off by default. On the server you pass a player orPlayer Help Texts Enabled root(everyone); on the client the change only affects that player.setShows or hides a game HUD component. Each component works on its own: hiding money keeps health, armour, the weapon, the clock and the rest of the HUD in place.Player Hud Component Visible "all"affects all of them at once (including the radar) and clears earlier settings of single components. Components:ammo,armour(orarmor),breath,clock,health,money,weapon,wanted,area_name,vehicle_name,radio,radar,all. The setting survives death and respawn; after reconnecting set it again (e.g. inonPlayerJoin).setTurns on the game's WASTED screen (text and red overlay) after the player dies. Off by default.Player Wasted Screen Enabled
Resources 2
callCalls a function exported by another resource (<export function="name"/>in itsmeta.xml) and returns its results.exports.resource:function(...)does the same. If the resource does not exist or is not running, a clear message appears in the console.getReturns the names of functions a resource exports inResource Exported Functions meta.xml(<export function="..."/>). In the current server version the list is empty.
Server 2
Timers 16
asyncRuns a function as a task (coroutine). The code in the task runs immediately until its first wait (sleep,await,waitForEvent). Then it yields and the server and the game keep running. When the wait is over, the task continues from where it stopped. This lets you write steps spread over time (a countdown, a database query, an HTTP response, waiting for a player) one after another, without nested callbacks and timers.awaitWaits for a result inside anasynctask. It takes two forms. The first is a starter function: it receivesresumeand starts something that ends in a callback (adbQueryquery,fetchRemote, a timer). When the callback callsresume(...),awaitreturns the same values. The second form is another task fromasync:awaitwaits until it ends and returns its results, and if that task failed, it re-throws the error (catch it withpcall).getReturns the state of a task fromTask Status async:"running"(waiting or working),"done"(finished) or"failed"(error). After the state it returns the values returned by the task function or, for"failed", the error message.getReturns the time until the timer's next call, the number of remaining repeats and the interval.Timer Details getReturns a description of the timer as a table:Timer Info remaining,repeats,interval,pausedandresource.getReturns the active timers of the calling resource. With an argument, only those whose interval does not exceed the given number of ms.Timers isChecks whether a value is a task returned byTask async.isChecks whether a value is an active timer. A one-shot timer stops being active after it fires.Timer isChecks whether a timer is paused byTimer Paused setTimerPaused.killStops a timer permanently. Its function will not be called any more.Timer resetRestarts counting the timer's interval from this moment.Timer setCalls a function after a given time, once, several times or forever.Timer setSets the time until the timer's next call without changing its interval.Timer Delay setPauses or resumes a timer. The remaining time is kept.Timer Paused sleepPauses anasynctask for the given time. Meanwhile other scripts, the server and the game run normally.sleep(0)waits until the next server frame (the same assetTimerwith interval 0).waitPauses anFor Event asynctask until an event happens. Returns the event'ssourceelement and its arguments. With a time limit it returnsfalseif the event did not happen in time. The handler and the limit timer are removed when the wait ends.
Utilities 13
formatConverts a number of seconds into a readable form:Duration "45s","3m 05s","1h 02m 05s". Fractions are truncated, negatives give"0s".formatWrites an integer with a separator every three digits (space by default): 1500000 →Number "1 500 000". Fractions are truncated.fromcolorSplits a colour stored as one number (e.g. fromtocolor) into r, g, b, a components - the inverse oftocolor.getReturns whether development mode is on (Development Mode setDevelopmentMode).getReturnsTick Count Seconds getTickCount()in seconds, with a fraction - more convenient for speed and animation calculations.isReturns whether the download progress box is enabled.Transfer Box Visible setTurns development mode on. On the client the second argument unlocks developer tools for pages in script browsers. On the server it stores a flag read withDevelopment Mode getDevelopmentMode(e.g. to enable test commands).setShows or hides the resource download progress box (a bar at the top of the screen). On the server the setting applies to all players, on the client - only to that player.Transfer Box Visible utfReturns the character with the given Unicode code, e.g.Char utfChar(261)→"ą".utfReturns the Unicode code of the text's first character, e.g.Code utfCode("ą")→ 261.utfReturns the length of a text in characters (not bytes). Important for non-ASCII letters:Len #"żółw"is 7 bytes, whileutfLen("żółw")is 4.utfReturns the byte position in a text moved by the given number of characters from a start position - useful when mixing UTF functions withSeek string.find.utfCuts a part of a text by character positions (from 1, both ends inclusive). Negative positions count from the end. Does not break non-ASCII letters, unlikeSub string.sub.
Vehicles 80
addFits a tuning part to a vehicle (spoiler, wheels, exhaust, nitro, hydraulics, bumpers…), visible and working for every player. The part must fit the model (Vehicle Upgrade getVehicleCompatibleUpgradeslists them). If the same slot already had a part, it is replaced; fitting the same part again changes nothing. New parts added withengineRequestModelwork too.areChecks whether the vehicle's headlights are on, i.e. whetherVehicle Lights On setVehicleOverrideLights(vehicle, 2)was set. Works on both sides.calculateCalculates which handling fields an engine would give in a model, without fitting it. It returns whatEngine Handling setVehicleEnginewould write into the vehicle, so it suits a preview in an engine shop.createCreates a vehicle in the world: model, position, rotation and number plate text.Vehicle fixRepairs a vehicle to factory condition: 1000 health, and every door, body panel, lamp and wheel returns to undamaged; a wreck stops being a wreck. It also cancels a scheduled wreck respawn. For one second after the repair the server ignores damage reports from the game so the old damage does not come back. Colour, tuning and plate stay as they were.Vehicle getReturns the name of the handling.cfg entry a model uses, e.g. 411 →Handling Line Name INFERNUS, 596 →POLICE_LA. New models fromengineRequestModeluse their base model's entry.getLikeModel Compatible Upgrades getVehicleCompatibleUpgrades, but for a model number, without creating a vehicle. Useful in a shop that shows parts before buying the car.getReturns the game's factory seat position for a model (for new models, of the base model), without script changes.Model Default Seat Position getReturns a model's current seat position and the source of the data:Model Seat Position script(set by script),dummy(from the model's helper point) ordefault(factory, from the game).getFinds the colour in the game's vehicle palette (0-127) most similar to the given RGB colour. Useful when a player picks a colour with a free colour picker and the script wants to store it as a palette number.Nearest Vehicle Palette Color getReturns a model's factory handling straight from the game files (Definitive Edition handling.cfg), without any script changes. Works on both sides.Original Handling getReturns a vehicle's colours. Without the second argument it gives four game palette numbers (when the car has RGB colours, the numbers are the nearest palette colours). WithVehicle Color rgb = trueit returns twelve numbers: r, g, b for colours 1-4 in turn, exactly as seen in the game.getReturns the tuning parts that fit this vehicle, based on the game's data (the carmods list plus wheels for regular cars). The result can be narrowed to one slot. Ideal for building a workshop menu.Vehicle Compatible Upgrades getReturns a vehicle model's parts as a table of name → visible. On the client, for a model from a file (Vehicle Components engineReplaceModel) it is the full list of .dff frames (body, doors, bonnet, bumpers,wheel_*_dummywheels, the author's variants); for game cars only parts changed by script. On the server only parts changed by script.getChecks whether a named part of a vehicle model is visible. On the client it also takes this player's local settings into account.Vehicle Component Visible getReturns the vehicle's driver (the occupant of seat 0), orVehicle Controller falsewhen nobody is driving.getOn the server: the gear number stored withVehicle Current Gear setVehicleCurrentGear(0 by default). On the client: the current gear computed like the SA gearbox from speed and handling (0 = reverse/neutral, 1-5).getReturns how dirty the vehicle's body is (0 clean - 1 dirty).Vehicle Dirt Level getReturns the door opening degree set withVehicle Door Open Ratio setVehicleDoorOpenRatio(0 = shut, 1 = open).getReturns the state of one door of a vehicle (0 shut, 1 ajar, 2 shut and damaged, 3 ajar and damaged, 4 missing). Door numbering as inVehicle Door State setVehicleDoorState.getReturns the vehicle's engine: the one fitted withVehicle Engine setVehicleEngineor, when none was fitted, the factory engine calculated from game data (withfactory = true). The second value is wear 0..1. Works on both sides.getChecks whether the vehicle's engine is running (set withVehicle Engine State setVehicleEngineState; destroying the vehicle also turns the engine off).getReturns a model's factory engine. Power is calculated from the game's handling, and the other data (torque, displacement, cylinders, mass) are a realistic estimate, marked withVehicle Factory Engine estimated = true. It gives a reference point for tuning systems.getReturns a vehicle's full handling as the game uses it: factory values from handling.cfg, overridden by model settings (Vehicle Handling setModelHandling), and finally by this vehicle's changes (setVehicleHandling,setVehicleEngine). Works on both sides.getReturns only the handling fields changed for this particular vehicle (Vehicle Handling Overrides setVehicleHandlingandsetVehicleEngine), without factory values. Useful for saving a car's tuning in a database.getReturns the headlight colour (white 255, 255, 255 by default).Vehicle Head Light Color getNewReturns the vehicle health floor set by setVehicleHealthFloor (0 = no floor).Vehicle Health Floor getReturns the indicator state: 0 off, 1 left, 2 right, 3 hazard. Works on both sides.Vehicle Indicators getReturns the names of all twelve lamps accepted byVehicle Lamp Names setVehicleLampState, in the order of numbers 0-11 (fromfront_lefttoindicator_rear_right). Groups (front,all…) are not in the list.getReturns the state of a lamp or lamp group set withVehicle Lamp State setVehicleLampState:'auto','on'or'off'. When the lamps in a group differ, it returns'mixed'.getReturns the state of all twelve lamps of a vehicle as a table of name →Vehicle Lamp States 'auto'/'on'/'off'.getReturns whether a vehicle lamp is working (0) or broken (1). Numbering as inVehicle Light State setVehicleLightState.getReturns the number of passenger seats of a vehicle or model (not counting the driver): e.g. 1 for a two-seater, 3 for a saloon. The data comes from the game, so the server only knows it once a client reports it (usually after the model first appears for a player); before that it returnsVehicle Max Passengers false.getTurns a vehicle name into a model number, ignoring letter case and surrounding spaces, e.g.Vehicle Model From Name "infernus"→ 411. It also recognises the names of new models fromengineRequestModel. Ideal for commands like/v infernus.getReturns the numbers of all models of a kind, e.g. all boats or helicopters. Useful for picking a random vehicle of a specific type.Vehicle Models Of Type getReturns a model's wheel diameter set withVehicle Model Wheel Size setVehicleModelWheelSize. On the client without a group name it returns a{ front_axle, rear_axle }table.getReturns a vehicle's name based on its model, e.g.Vehicle Name "Infernus","Landstalker". For a new model fromengineRequestModelit returns the name given at registration or the base model's name. Works on both sides.getReturns a vehicle name for a model number, e.g. 411 →Vehicle Name From Model "Infernus", without creating a vehicle. For a number outside 400-611 that is not a new vehicle it returnsfalse.getReturns the number of nitro charges stored withVehicle Nitro Count setVehicleNitroCount(0 by default, -1 = unlimited).getReturns the nitro level stored withVehicle Nitro Level setVehicleNitroLevel(1 by default).getReturns the player or ped sitting in the given seat of a vehicle. Seat 0 is the driver, 1 the front passenger, 2 and 3 the rear seats.Vehicle Occupant getReturns everyone (players and peds) sitting in the vehicle as a table of seat number → occupant. Empty seats are not in the table, so loop over it withVehicle Occupants pairs, notipairs(seat 0 is not an array index).getReturns the forced light state: 0 no override, 1 off, 2 on.Vehicle Override Lights getReturns the vehicle's paintjob number: 0-2, or 3 when it has none. Works on both sides.Vehicle Paintjob getReturns the colour with the given number from the game's vehicle palette (0-127) and its name. The RGB values are exactly what the Definitive Edition draws, so they suit e.g. a colour preview in a paint shop.Vehicle Palette Color getReturns the damage level of a body part (0 intact - 3 badly damaged). Numbering as inVehicle Panel State setVehiclePanelState.getReturns a vehicle's performance in a player-friendly form: power in kW and HP, torque, mass, 0-100 km/h time and top speed. You can pass a vehicle (its engine and wear are used) or a model number, optionally with an engine to compare.Vehicle Performance getReturns the vehicle's licence plate text.Vehicle Plate Text getNewReturns the vehicle immunity table set by setVehicleProofs.Vehicle Proofs getChecks whether the vehicle's siren is switched on withVehicle Sirens On setVehicleSirensOn. Works on both sides.getReturns the tail light colour (255, 0, 0 by default).Vehicle Tail Light Color getReturns the kind of vehicle (English name):Vehicle Type Automobile,Bike,BMX,Quad,Monster Truck,Boat,Helicopter,Plane,Train,Trailer. Accepts a vehicle or a model number.getReturns the vehicle kind for a model number (likeVehicle Type From Model getVehicleType). A new model fromengineRequestModelhas its base model's type.getReturns the names of all vehicle kinds, sorted alphabetically.Vehicle Type Names getReturns the ID of the part fitted in the given tuning slot, or 0 when the slot is empty. Slot numbers 0-16 are described byVehicle Upgrade On Slot getVehicleUpgradeSlotName.getReturns the IDs of all tuning parts fitted to a vehicle. Works on both sides.Vehicle Upgrades getReturns the tuning slot number (0-16) a part belongs to.Vehicle Upgrade Slot getReturns the English name of a tuning slot, given a slot number or a part ID. Slots: 0 Hood, 1 Vent, 2 Spoiler, 3 Sideskirt, 4 Front Bullbars, 5 Rear Bullbars, 6 Headlights, 7 Roof, 8 Nitro, 9 Hydraulics, 10 Stereo, 11 Unknown, 12 Wheels, 13 Exhaust, 14 Front Bumper, 15 Rear Bumper, 16 Misc.Vehicle Upgrade Slot Name getReturns the names of all 17 tuning slots in number order (the first element = slot 0).Vehicle Upgrade Slot Names getReturns the vehicle's two appearance variants (255 = none). Works on both sides.Vehicle Variant getNewReturns the vehicle's wheel grip multiplier (the product of every resource's multiplier, 1 = normal).Vehicle Wheel Grip getReturns the state of a vehicle's four wheels in order: front left, rear left, front right, rear right (0 inflated, 1 flat, 2 fallen off).Vehicle Wheel States getNewReturns the vehicle's window darkness in percent (0 = normal windows) and, if a colour is set, also its r, g, b components.Vehicle Window Tint isChecks whether a number is a vehicle model: 400-611 from the game or a new vehicle registered withValid Vehicle Model engineRequestModel.isChecks whether a vehicle is a wreck, i.e. it was destroyed (Vehicle Blown blowVehicleor an explosion in the game) and has not been repaired or respawned yet. A wreck cannot be driven.isChecks whether the vehicle's doors are locked withVehicle Locked setVehicleLocked.isReturns whether nitro was switched on withVehicle Nitro Activated setVehicleNitroActivated.isReturns whether nitro is recharging.Vehicle Nitro Recharging isReturns whether the vehicle stands on its wheels on the ground.Vehicle On Ground isChecks whether the vehicle's "TAXI" light is on. Works on both sides.Vehicle Taxi Light On isReturns whether a wheel touches the ground.Vehicle Wheel On Ground removeRemoves a fitted tuning part from a vehicle. Removing nitro also clears the stored nitro charges.Vehicle Upgrade setSets a vehicle's paint colours as any RGB colours, visible to every player. A vehicle has up to four colours: 1 = main paint, 2 = second colour (stripes, roof, rims depending on the model), 3 and 4 = extra parts of some models. Pass only the first three numbers and the second colour will match the first. Colours not in the game palette are drawn exactly, without rounding to the palette.Vehicle Color setShows or hides a named part of a vehicle model. On the server the change applies to every player ; on the client it applies to the local player only and takes priority over the server's setting. It works on the frames of a model from a file (Vehicle Component Visible engineReplaceModel): the author's variants (spoiler_1,extra1…), doors, bonnet, bumpers. The client-sidegetVehicleComponentslists the names for a given vehicle.setTurns a vehicle's engine on or off for every player. With the engine off the vehicle does not drive even when the driver presses the throttle (it can only roll). By default the engine starts by itself when a driver gets in; afterVehicle Engine State setWorldSpecialPropertyEnabled("vehicle_engine_autostart", false)it does not, and an RP server can build its own ignition on a key or command.setChanges the driving parameters (handling) of one vehicle for every player: mass, top speed, acceleration, grip, brakes, steering, suspension and other handling.cfg fields. The game gets its own copy of the handling entry for this car, so other vehicles of the model do not change. You can pass one field with a value, a whole table of fields, orVehicle Handling nilto go back to the factory handling (includingsetModelHandling). Field names; the list:getHandlingFieldNames.setLocks or unlocks a vehicle's doors for every player. Players cannot get into a locked vehicle (the game will not start entering). People already inside can still get out normally.Vehicle Locked setChanges the wheel diameter of a vehicle model. On the client it changes the wheels of vehicles with a custom model (Vehicle Model Wheel Size engineReplaceModel) for this player; game cars' wheels stay as they are. On the server it only stores the value for scripts.setForces the state of a vehicle's lights for every player. In Trilogy Hub the game does not switch the lights on at dusk by itself, so the headlights only shine after setting 2. Single lamps (brake, reverse, indicators) are set withVehicle Override Lights setVehicleLampState.setChanges the vehicle's licence plate text, visible to every player. A plate holds at most 8 characters; longer text is cut. Use letters, digits and spaces, as the game's plate font has only those.Vehicle Plate Text
Weapons 7
getReturns the inventory slot (0-12) a weapon ID goes into.Slot From Weapon getReturns a weapon ID from its name. Case does not matter, and a numeric string (Weapon IDFrom Name "30") works too.getReturns a sorted list of every weapon ID used in the game.Weapon IDs getReturns the model ID a ped holds in hand for a weapon.Weapon Model From ID getReturns the GTA San Andreas weapon name for an ID (0-46).Weapon Name From ID getReturns the weapon IDs that belong to an inventory slot.Weapons In Slot isChecks whether an ID is a weapon used in the game (0-46, skipping unused numbers).Valid Weapon ID
World 48
areReturns the value stored withTraffic Lights Locked setTrafficLightsLocked(falseby default).getReturns the value fromBirds Enabled setBirdsEnabled(trueby default).getReturns the value fromBlur Level setBlurLevel(36 by default).getReturns the map region name at a point (City Name "Los Santos","San Fierro","Las Venturas","Red County","Flint County","Whetstone","Bone County","Tierra Robada"); the same asgetZoneName(x, y, z, true).getReturns the colour filter set withColor Filter setColorFilter. On the client it returns the local filter, or the server filter without it.getReturns the value fromCorona Reflections Enabled setCoronaReflectionsEnabled(falseby default).getReturns the value fromGrain Level setGrainLevel(0 by default).getReturns the value fromGrain Multiplier setGrainMultiplier(1 by default).getReturns the world gravity strength (0.008 by default).Gravity getReturns the ground height under a point. On the client it asks the game (real terrain and buildings). The server does not know the map terrain, so there it only considers script objects and the water level; it often returnsGround Position false.getReturns the heat haze settings stored withHeat Haze setHeatHaze.getReturns the value fromInterior Furniture Enabled setInteriorFurnitureEnabled(trueby default).getReturns the value fromNear Clip Distance setNearClipDistance(0.3 by default).getReturns the value fromPeds LODDistance setPedsLODDistance(60 by default).getReturns the sky colours stored withSky Gradient setSkyGradient.getReturns the sun colour stored withSun Color setSunColor.getReturns the sun size stored withSun Size setSunSize(1 by default).getReturns the current game hour and minute on the server (the same that players see).Time getReturns the traffic light state stored withTraffic Light State setTrafficLightState(0 by default).getReturns the value fromVehicles LODDistance setVehiclesLODDistance(500 by default).getReturns the water colour stored withWater Color setWaterColor.getReturns the water level stored withWater Level setWaterLevel; when not set, for a given point it returns 0 (sea level).getReturns the wave height stored withWave Height setWaveHeight.getReturns the current weather and the weather a smooth change fromWeather setWeatherBlendedis heading towards (ornil).getReturns the wind stored withWind Velocity setWindVelocity. On the serverfalsewhen not set; on the client 0, 0, 0 then.getReturns the box enclosing a whole zone (all its parts) with the given name: minimum and maximum coordinates. When there is no such district it looks for a region.Zone Bounds getReturns the centre of the zone box fromZone Center getZoneBounds. Useful e.g. to place a "Go to Idlewood" marker. The centre need not be on the ground, or inside the zone itself if its shape is irregular.getReturns the number of zone (district) rectangles and region rectangles in the map data.Zone Count getReturns the name of the district (map zone) at a point, e.g.Zone Name "Grove Street","Idlewood","Downtown Los Santos"- what the game shows on screen when you enter a new area. WithcitiesOnly = trueit returns the region name ("Los Santos","San Fierro","Las Venturas","Red County"…). Works on both sides on the data of the game's 356 zones, without asking a client.getReturns a sorted list of all district names (without duplicates) or, withZone Names citiesOnly = true, region names. Good for selection lists in panels.isChecks whether aim assist is allowed (Aim Assist Enabled setAimAssistEnabledon the server). On the client it tells whether the server allows it.isReturns whether a garage was marked as open withGarage Open setGarageOpen. Works on both sides.isChecks whether a point lies in a zone or region with the given name (case-insensitive). A zone can consist of many rectangles; each of them counts.Inside Zone isChecks whether nothing blocks the segment between two points. On the client it asks the game (terrain, buildings, objects, vehicles, peds, collisions from .col files). On the server it uses a simplified model: script elements as spheres, without map terrain and buildings, so it is only an approximation.Line Of Sight Clear isReturns the value fromVolumetric Shadows Enabled setVolumetricShadowsEnabled(falseby default).isReturns the value fromWater Drawn Last setWaterDrawnLast(falseby default).isReturns whether a special world property is enabled: the value fromWorld Special Property Enabled setWorldSpecialPropertyEnabledor the default (e.g.randomfoliageandvehicle_engine_autostarton by default,hovercarsoff).processFinds the first obstacle on the segment between two points and returns the hit details. On the client it asks the game (terrain, buildings, objects, cars, peds, collisions from .col files) and returns plenty of data: hit point, element, surface normal, material, lighting, body or vehicle part, and on request the map object model with its position. Each call waits about one game frame; while the world is still loading (loading screen) it returnsLine Of Sight falseat once. On the server it uses a simplified model (element spheres, no terrain or buildings).removeStores the removal of San Andreas map objects with a given model within a sphere of the given radius. Can be called many times; each call adds an entry. If called before the game has loaded its models (e.g. while the player joins), it waits and applies once loading finishes.World Model resetRemoves the colour filter. On the server for all players; on the client it removes the local filter, and the server filter (if any) stays.Color Filter resetClears the sky colours fromSky Gradient setSkyGradient.restoreRemovesWorld Model removeWorldModelentries for a model whose sphere touches the given sphere. Without coordinates it removes all entries of that model. It removes the calling resource's own entries first, and other resources' entries only when it has none of its own.setApplies a colour filter to the game image: two RGBA layers multiply the colours of the world, each to the degree of its alpha (alpha 0 = the layer changes nothing, 255 = the full layer colour). On the server every player gets the filter, on the client only this player (it takes priority over the server filter). Script texts and windows are not tinted.Color Filter setStores the sky colours: top (zenith) and bottom (near the horizon), each RGB 0-255.Sky Gradient setSets the in-game time for every player. From then on the clock keeps running by itself (unless it is stopped withTime setTimeFrozen); one game minute lasts one second by default (setMinuteDuration). The time of day changes the lighting, the sky colour and whether it is dark.setChanges the weather immediately for every player. Numbers 0-22 are San Andreas weathers, e.g. 0 extra sunny, 1-7 different mixes of sun and clouds, 8 storm, 9 fog, 16 rain, 19 sandstorm. It stops a smooth change started withWeather setWeatherBlended.setSchedules a smooth weather change: the server switches to the new weather after about two game hours.Weather Blended testChecks whether a segment crosses the water surface (by the level fromLine Against Water getWaterLevel) and returns the crossing point.
XML 18
xmlCopies a node (with its children and attributes) into a new document at a new path. The copied node becomes the root of the new document, which must be saved withCopy File xmlSaveFile.xmlAdds a new child node with the given name at the end of the parent's children.Create Child xmlCreates a new XML document with a root node of the given name. The document is in memory; it reaches the disk only afterCreate File xmlSaveFile. An existing file is overwritten on save.xmlRemoves a node together with its children. The root node cannot be removed.Destroy Node xmlFinds a child with the given tag name.Find Child indexpicks which one (from 0) among children with that name.xmlLoads an XML file and returns its root node, from which you can read children and attributes. On the server the path is relative to the resource folder (you cannot leave it). On the client it reads the script's own files and thenLoad File <file>files sent by the server; a":other/file.xml"path points to another resource's file. RememberxmlUnloadFilewhen the document is no longer needed.xmlLoads an XML document directly from a string (e.g. received withLoad String fetchRemote), read-only. Returns the root node.xmlReturns the value of a node attribute as text (convert numbers withNode Get Attribute tonumber).xmlReturns all node attributes as a name → value table.Node Get Attributes xmlWithout an index returns a table of all the node's children; with an index (from 0) - one child.Node Get Children xmlReturns the node's tag name (e.g.Node Get Name "spawn"for<spawn/>).xmlReturns the node's parent.Node Get Parent xmlReturns the text inside a node (e.g.Node Get Value "Hello"for<msg>Hello</msg>).xmlSets a node attribute; numbers and other values are converted to text.Node Set Attribute nilorfalseremoves the attribute.xmlChanges the node's tag name.Node Set Name xmlSets the text inside a node (replaces the previous one).Node Set Value xmlSaves the whole document (that the node belongs to) to its file. Does not work for read-only documents or those fromSave File xmlLoadString.xmlFrees a document from memory. All its nodes become invalid. Unsaved changes are lost.Unload File