Skip to Content
ScriptingOverview
Open in ChatGPTOpen in Claude

Choose the runtime and execution side first

A ScRT is a scripting runtime. FiveM exposes resource scripting through Lua, JavaScript and C#. Choosing a language does not change which machine owns the code or make client-side state authoritative. The official development fact sheet  is a navigation aid; check track-specific references before copying its historical examples.

Three execution contexts

ContextAppropriate workImportant boundary
Server scriptValidated game rules, persistence, permissions and session management.Client arguments are untrusted; asynchronous work must revalidate session identity.
Client game scriptInput, game-native rendering, local entities and effects.It is downloaded to and controlled by the player; keep secrets and authoritative purchases elsewhere.
Browser NUIHTML/CSS/JavaScript interfaces and browser-side interaction.Browser APIs are not game natives; requests cross an explicit NUI callback boundary.

A shared manifest entry runs in both server and client contexts. It does not create shared memory or a secret configuration channel. A resource can combine languages through supported same-side exports and events, but argument and lifecycle contracts still matter.

Build the first working resource

Use the complete Lua starter, JavaScript starter, or C# project and build guide. Each identifies the filenames, startup commands, expected output and failure paths. Start with a private server where connection and player spawning already work.

Then read resource lifecycle, manifest entries, events and exports. A dependency such as stock chat or spawnmanager must actually be running; a framework replacement may have different contracts.

Find the native, not a similarly named function

A native is a platform/game function exposed to scripts. Select its client/server API set, argument order, types and return convention in native lookup. The local player can be obtained with PlayerPedId() in a Lua client script; a server script uses its own player/session and entity APIs rather than assuming that client call exists there.

Model hashes, entity network IDs, local ped handles and server player IDs are different values. Use ID conversions and the game-reference catalogs before substituting a number into a native. For language-specific helpers use Lua APIs, JavaScript APIs or the C# runtime lab.

Diagnose hitches with evidence

A hitch warning reports delayed work; it does not identify the guilty resource by itself. Investigate expensive loops, synchronous or oversized work, slow database operations and load on the host. Use profiler captures to locate the work and compare the same scenario before and after a change.

The client resource monitor, resmon, shows per-resource timing and memory information. Access can be restricted. The old fact sheet’s +set moo 31337 shortcut applies to its Legacy workflow; the reviewed Enhanced contract replaces that mechanism with server-controlled sv_devMode. Do not weaken production controls merely to make a diagnostic command run. See client console commands, cross-track migration and resmon usage.

For repeated game work, yield appropriately; frame-dependent drawing and an occasional background observation need different intervals. Do not put a database query in a per-frame loop. Lua scheduling and JavaScript scheduler handoff cover these distinctions.

Continue by task

Build an interface with NUI and current callbacks; use Scaleform for that separate rendering system. Configure voice for the chosen track. Work with state bags, collection-based clothing, or built-in fuel consumption only after checking ownership and version assumptions.

The answer finder groups these guides by the task being attempted. The source inventory distinguishes current local treatments, historical material, upstream placeholders and external generated catalogs rather than presenting every index as another implemented API.