Documentation
Lua scripting in Trilogy Hub
You write Trilogy Hub servers in Lua, the same way as in MTA:SA: resources with meta.xml, events, exports and the same function names. Here you will find every function and event described with examples.
SserverCclientBboth sides
New functions and events! 15
onNewAn element's data changed - through setElementData on the server or in a client script.Client Element Data Change setNewSets a vehicle health floor: bullets, fire, explosions and collisions will not take the health below this value. A floor of 250 or more stops the car from catching fire or exploding from damage. A script can still go lower with setElementHealth or blowVehicle. 0 turns the floor off.Vehicle Health Floor setNewSets what a vehicle is immune to: bullets, fire, explosions, collisions and melee. Works for every player. AllVehicle Proofs falserestores normal behaviour. setVehicleDamageProof also makes it immune to everything at once.setNewChanges a vehicle's wheel grip with a multiplier (1 = normal, 0.5 = half, 1.5 = half again as much). Each resource has its own multiplier and the car gets their product. 1 removes the resource's multiplier, and stopping a resource removes its multipliers by itself.Vehicle Wheel Grip setNewTints a vehicle's windows for every player and can give them a light colour. The darkest is 80% - a higher value also gives 80%, because the glass should still look like glass: reflections stay and you can still see a bit of the interior. The colour only tints the glass, the darkening does most of the work. Darkness 0 without a colour restores the normal windows.Vehicle Window Tint createNewLays an image on the ground - a track, a stain or a place marker. The image follows slopes and kerbs instead of hanging flat above them. It is drawn up to 150 m from the camera, and with a lifetime set the last second fades out smoothly. The decal stays until destroyGroundDecal or until the resource stops.Ground Decal destroyNewRemoves a decal made with createGroundDecal.Ground Decal setNewChanges the colour of a decal made with createGroundDecal.Ground Decal Color getNewFinds a San Andreas map model without collision that the segment passes through: graffiti, car wash brushes, meshes with transparency.World Model On Line processLineOfSightdoes not see such models because it passes through them. When the segment crosses several of them, the smallest one wins (e.g. graffiti on a building wall). Models with collision are skipped, sinceprocessLineOfSightfinds those. The result fitsremoveWorldModeldirectly.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
Start here
Getting startedYour first resource in five minutes: a folder,
meta.xml, one server script and one client script.Resources and meta.xmlEverything about meta.xml: server, client and shared scripts, files for players, exports and download order.ConventionsRules shared by the whole API: script sides, elements, root and source, coordinates and error handling.Server configurationEvery setting in server-config.json: name and port, the server list, relay, player limits, file downloads and updates.Catalogue and effects
ParticlesMoving particles simulated by the game: 14 ready-made effects, custom settings, attaching to vehicles and players, server effects everyone sees.CursorA cursor drawn by the game: built-in shapes, custom images and one cursor for
dxDraw, GUI and browsers.VehiclesEvery San Andreas vehicle with its model ID and name, grouped by type. Each vehicle rendered straight from the game.SkinsEvery San Andreas character skin (ped) with its model ID. Each character rendered straight from the game.WeaponsEvery San Andreas weapon with its ID, name, model and slot. Each weapon rendered straight from the game.MarkersAll five marker types with in-game pictures: a cylinder to step into, a checkpoint, a ring, an arrow and a corona.Functions and events
Server functionsFunctions available in
type="server" scripts. They run on the server and see every player.741 documented functionsClient functionsFunctions available in type="client" scripts. They run in each player's game separately: drawing, keys, interface.529 documented functionsShared functionsFunctions that work on both sides. Use them in server, client and shared scripts.505 documented functionsServer eventsEvents triggered on the server. Handle them with addEventHandler in a server script.89 documented eventsClient eventsEvents triggered in the player's game. Handle them with addEventHandler in a client script.83 documented eventsDownload documentation (.md)The whole documentation in one text file: to read offline, in an editor or in a repository.Categories
Accounts27Administration and bans19Audio9Bitwise operations12Blips33Browser72Camera20Chat and console17Clothes32Collision shapes31Cursor5Database9Discord10Drawing (dx)94Effects21Elements110Events16Files20Fire12Game engine88Input and controls37Interface (GUI)161Lights18Maps3Markers20Math, vectors and matrices7Miscellaneous107Objects26Particles11Peds111Permissions (ACL)26Pickups16Players134Projectiles9Resources47Server25Shaders9Sound (client)28SVG6Teams8Text displays20Timers16Utilities30Vehicles226Weapons35World136XML18
What it looks like
A whole resource is a folder with meta.xml and scripts. This one greets the player in chat and puts them near Grove Street.
addEventHandler("onPlayerJoin", root, function()
spawnPlayer(source, 2495.3, -1687.0, 13.5)
outputChatBox("Welcome to Grove Street, " .. getPlayerName(source) .. "!", source, 255, 122, 34)
end)
<meta>
<info name="Welcome" author="You" version="1.0" type="script" />
<script src="server.lua" type="server" />
</meta>