ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Trilogy Hub
  2. For creators

Lua scripting for creators

The Trilogy Hub API is written in MTA:SA style: resources, meta.xml, events, exports and the same function names. If you know these rules, you can start right away.

What does a script look like?

A resource is a server script, a client script and meta.xml. Below: a car on command with an RGB colour and plate, time of day, weather, Definitive Edition slow motion and a client-side dialog box.

-- Car on command: RGB colour, headlights, custom plate
addCommandHandler("auto", function(player)
    local x, y, z = getElementPosition(player)
    local car = createVehicle(536, x + 3, y, z)  -- Blade
    setVehicleColor(car, 255, 122, 34, 20, 20, 20)
    setVehicleHeadLightColor(car, 255, 180, 90)
    setVehiclePlateText(car, "GROVE 4L")
    warpPedIntoVehicle(player, car)
end)

-- Sunset over Los Santos
setTime(19, 30)
setWeatherBlended(1)

-- Weapon wheel slow motion from Definitive Edition
setSlowMotionEnabled(true, "wheel")

What works the same as in MTA?

  • A bad argument does not stop the script. The function returns false and logs a Bad argument @ 'setPlayerMoney' warning.
  • Coordinates as x, y, z or a Vector3.
  • Custom events with addEvent, client-to-server events with addEvent('name', true).
  • Exports: exports.resource:function() and call().
  • Numbering: GUI list rows from 0, columns from 1, weapon slots 0 to 12.

What is ready out of the box?

  • setSlowMotionEnabled: slow motion on the weapon wheel and during stunts, from Definitive Edition.
  • Built-in UI themes switched with one function: guiSetTheme, guiRegisterTheme.
  • Ready-made elements: a guiNotify notification, a guiMessageBox dialog, a guiCreateSlider slider.
  • setLoadingScreen: image, name and tips on the server loading screen, with one function.

What does the API cover?

  • Players
  • Peds
  • Clothes
  • Vehicles
  • Weapons
  • Projectiles
  • Objects
  • Pickups
  • Markers
  • Blips
  • Collision shapes
  • World
  • Lights
  • Fire
  • Effects
  • Camera
  • Audio
  • Interface (GUI)
  • Drawing (dx)
  • Text displays
  • Cursor
  • Input and controls
  • Chat and console
  • Teams
  • Accounts
  • Permissions (ACL)
  • Admin and bans
  • Database
  • Files
  • XML
  • Resources
  • Events
  • Timers
  • Maps
  • Math and vectors

Every function is described in the Lua documentation.

Tools

The collision generator makes a .col file from an FBX, OBJ, glTF, DFF or 3DS model: you set the triangle count, the mode and the surface, and see the result in 3D before it goes into your resource.

Questions

How is Trilogy Hub different from MTA:SA?

They are two separate projects for different versions of the game. MTA:SA runs on the original GTA San Andreas, while Trilogy Hub runs on Definitive Edition (Unreal Engine 4). Scripting works in a similar way, and the Trilogy Hub launcher also gives you an account, friends and chat.

Will my MTA:SA scripts work?

Partly. The Trilogy Hub API uses a similar model: resources with meta.xml, events, exports and the same names for many functions. A ready-made resource needs reviewing, because not every function has a counterpart.

Grove Street is waiting.