FreeScript
tLib
by tommy141x · version 2026.11.06 · updated 3 days ago
No reviews yet
- Downloads
- 0
- Reviews
- 0
- Size
- 2.6 MB
- Code check
- Checked
- Licence
- MIT
- Released
- Nov 2026
A shared utility library for Helix & FiveM resources
tLib
A shared utility library for FiveM resources: one NUI menu, dialog and toast system with
themes, 40 Lua import modules (access, permission, config, KVP, settings, platform and the
rest), and TypeScript/NUI utilities for resource frontends.
FiveM is the only supported runtime. Everything goes through an internal
SystemsMenu System
One NUI menu, shared by every resource on the server. tLib owns the screen, the
keyboard and the permission check; a consumer declares pages and handles rows.
The API is declarative and split across the two sides. Pages register on the server,
which answers every open with that player's own ACE-filtered tree, so there is no path to a
row the player is not entitled to. The client registers behaviour: handlers, presenters
that fill rows in as they are shown, and hooks for entering or leaving a page.
Menu IDs are namespaced: every page a resource registers must be
export below takes an optional trailing
cannot identify the caller; pass it as its own argument, never as the result of a call
in the last argument slot (
lands in
Start here: Developing modular menu resources covers a complete standalone consumer, registration/restart lifecycle, stable host slots, ownership and placement.
Server — declaring the tree
Skin
Client — behaviour
A shared utility library for FiveM resources: one NUI menu, dialog and toast system with
themes, 40 Lua import modules (access, permission, config, KVP, settings, platform and the
rest), and TypeScript/NUI utilities for resource frontends.
FiveM is the only supported runtime. Everything goes through an internal
Platform adapter.SystemsMenu System
One NUI menu, shared by every resource on the server. tLib owns the screen, the
keyboard and the permission check; a consumer declares pages and handles rows.
The API is declarative and split across the two sides. Pages register on the server,
which answers every open with that player's own ACE-filtered tree, so there is no path to a
row the player is not entitled to. The client registers behaviour: handlers, presenters
that fill rows in as they are shown, and hooks for entering or leaving a page.
Menu IDs are namespaced: every page a resource registers must be
owner:name. Everyexport below takes an optional trailing
declaredOwner, used only where the platformcannot identify the caller; pass it as its own argument, never as the result of a call
in the last argument slot (
f(json.decode(x)) expands to two values and the secondlands in
declaredOwner).Start here: Developing modular menu resources covers a complete standalone consumer, registration/restart lifecycle, stable host slots, ownership and placement.
tlib.lifecycle (shared import) and tlib.menuhost (server import) both expose API version = 1; they run in the caller's VM and contain no consumer-specific policy.Server — declaring the tree
DefineMenuNamespace(spec)— Required first.{ ace, catalog?, order?, capabilities?, theme? }.acegates the whole namespace.RegisterMenuDomains(domains)— Rate/cooldown domains actions may be assigned to.RegisterMenu(menu, definition)— One page plus its authority:definitionis{ ace, actions = { [itemId] = { ace, run?, clientAction?, cooldown?, fixedValue?, domain? } }, theme?, rootVisible? }.rootVisible = falseomits the automatic shared-root link without changing direct access or permissions.UnregisterMenu(menuId)RegisterMenuAuthority(spec)/UnregisterMenuAuthority()— Answer for rows this resource does not own.OnMenuSnapshot(hook)— Adjust a player's tree as it is built for them.RefreshMenus()— Re-push every open menu.
PatchMenuItem(menuId, itemId, changes)/PatchMenuAction(itemId, changes)— The second finds the page itself.SetMenuLinks(menuId, links)— Replace dynamic submenu rows on a page you own;linksis an array of ordinarykind = 'submenu'rows, or{}to remove them. Base rows/actions are unchanged. Targets remain permission-filtered and disappear when unavailable. A catalogued page with links travels as a full descriptor (100 rows total, the existing descriptor schema limit); removing all links restores compact delivery.SetMenuItemVisible(itemId, visible)SetPlayerMenuOptions(source, itemId, options)— One player's own choices for a selector.SetMenuNamespaceTheme(theme)/SetMenuTheme(menuId, theme)—nilclears.
{ accent = '#rrggbb', banner = { dictionary, texture } | { url }, theme = '', skin = 'default' | 'vmenu' }. Every field is optional; at least one must be set. The same shape is accepted at all three layers, resolved most-specific-first and flattened field by field: the page's own theme, then the theme of the resource that created it, then the interface default. A resource that sets only an accent therefore keeps the interface's banner.skin selects the presentation rather than a colour, so it is a closed set rather than a free string:Skin
default, The shared look. The same controls, checkboxes, sliders and face as tLib's dialogs and toasts.vmenu, The legacy vMenu-styled presentation, kept switchable for a test or a side-by-side comparison.theme names a theme registered with AddTheme, which is where full CSS-variable control lives. To make a menu, its toasts and its dialogs match, register one theme id setting the nui-* variables (see the Theme System section) and pass that id as the menu's theme, as ShowDialog's theme option, and as ShowToast's theme argument.Client — behaviour
RegisterMenuActions(handlers)—{ [name] = function(value, context) end }, registered as one table: all of it installs or none of it does.RegisterMenuCatalogProvider(provider)— Build this resource's catalog once, off a function that may yield.RegisterMenuHooks(spec)—{ snapshot, enter, leave, page, selection, close }.entermay refuse a navigation.RegisterMenuPresenter(spec)/UnregisterMenuPresenter()— Fill rows in as a page is presented.RegisterMenuStrings(dictionaries)— Translations for this resource's rows.ConfigureMenuInterface(spec)— The root page. One screen, so the last caller wins.SetMenuEffect(name, enabled, definition)— A handler that keeps running after the row was activated, re-checked against the player's grants while it does.PublishMenuItem(name, changes),SetMenuItemState(name, value),GetMenuItemState(name),ExecuteMenuAction(name, value, context)OnMenuActionsCleanup(fn)/OnMenuActionsPersist(fn)
OpenMenu(menuId?)— Re-checks the page against a fresh permission-filtered snapshot.CloseMenu()— The same teardown the close key runs. Does not toggle: closing a menu that is not open answersfalse, 'Menu is not open', so a caller that meant to close one is never the reason a fresh one appeared. Needed beforeOpenMenu, which refuses while a menu is already up.IsMenuVisible(),GetMenuStackIds(),NavigateMenu(menuId),InvalidateMenuContext()- `SetMe