Skip to main content

Add the import

fxmanifest.lua
lua54 'yes' is required. Start your resource after ug-core, and never call exports['ug-core'] directly: the import does it for you, with checks.
The import defines one global in your resource: UgCore.

What runs where

The import loads part of ug-core into your resource and proxies the rest to ug-core’s exports:

Local, in your resource

Callback, Network, Events, Schema, Logger, Enums, Modules, Version, Lifecycle, and RateLimit on the server.No export call per request. Logger prints in your resource’s console.

Proxied to ug-core

Config, Guard and Hooks on the server, Config on clients, and every enabled module namespace: Players, Accounts, Jobs and the rest.Data crosses the export boundary as a copy.
Your callbacks and net events run in your resource, but share central state with ug-core: the Guard score of each player and the global request budget.

Errors you can get

The UgCore root is read-only and checks every name you use:
Errors point to the line in your resource that caused them.

Waiting for ug-core

If your resource starts while ug-core is still booting, module namespaces raise UgCore.Accounts is not available until ug-core is ready. Wait first:
server.lua
UgCore.Lifecycle.On('Ready', handler) does the same without blocking, and runs right away if ug-core is already ready.

Optional modules

Check before using a module your resource can live without:
UgCore.Modules.Require('accounts') raises a clear error when a module you cannot live without is disabled.

Editor support

UgCore is fully annotated for the Lua language server. Add the ug-core folder to your library to get autocomplete, types and typo checks. Add it next to the FiveM natives in your VS Code settings:
settings.json
A workspace.library in a .luarc.json replaces the list from your editor settings, including the FiveM natives. Keep library paths in one place.