Beginner-to-shipping FiveM coding course. Built by a working FiveM dev. No fluff, no padding, every Lua line explained.
If you've ever opened a FiveM resource on GitHub and felt lost - this fixes that.
You'll get the most out of this if you:
- Have done a little code before (any language: JS, Python, C#, doesn't matter). You know what a variable, a function, and a loop are.
- Want to write server-side scripts, UI menus, jobs, or full game systems for a FiveM server.
- Don't know Lua. You learn it here.
- Don't know FiveM internals. Same.
Total beginners (never coded at all) - start with freeCodeCamp's JavaScript course first. Come back when you're comfortable with if, for, and functions.
By the end:
- Custom commands and chat events
- Job systems with permissions
- Shops with money + inventory + database logging
- HTML/React UIs that talk to the game
- Resources that don't tank your server's framerate
- Code that doesn't get exploited the day you ship it
| Thing | Why |
|---|---|
| PC with FiveM installed | You can't test without playing |
| Code editor (VS Code recommended) | Syntax highlighting, file explorer, terminal |
| Local FiveM dev server (txAdmin is the easiest) | You need a server to load your code into |
| Basic Git (GitHub Desktop if you hate the command line) | To version-control your work |
| A MySQL client (HeidiSQL on Windows, DBeaver cross-platform) | To poke at the database |
VS Code extensions worth installing day one:
- sumneko.lua - Lua language server (autocomplete, errors)
- overextended.cfxlua-vscode - FiveM native autocomplete
Read in order. Each folder builds on the last. Skipping = confusion later.
01-basics → what FiveM is, Lua, client/server, resources
02-events → how scripts talk to each other
03-natives → the GTA V API
04-database → MySQL with oxmysql
05-frameworks → Qbox / QBCore basics
06-ox-libraries → ox_lib, ox_target, ox_inventory
07-nui → UI (HTML/CSS/JS, then React)
08-security → don't get exploited
09-performance → don't freeze the server
10-first-projects → build 3 real things end-to-end
Each lesson ends with Next: <file> so you always know where to go.
If you feel lost, jump to INDEX.md for the full map and shortcut paths.
Every lesson follows the same shape so you know what to expect:
- Plain-English summary at the top - what is this, why do you care
- Code examples with every line annotated - no "magic" lines
- Common mistakes - the bugs that bite beginners
- Optimization & security callouts where they matter
- TL;DR - the takeaway in 5 bullets
- Sources - links to the official docs so you can dig deeper
Code blocks look like this:
-- declare a local variable. "local" = scoped to this file/block, NOT shared globally
local playerName = 'Sam'
-- print it to the server console (F8 in-game, or your terminal)
print(playerName)Every non-trivial line gets a comment. You shouldn't have to guess what any line does.
These come back in every lesson. Burn them in now:
- Client = hostile. Server = trusted. Always validate on the server. Never trust what the client sends.
- No secrets in client code. Players can read your client
.luafiles. Webhooks, API keys, prices - server only. local src = sourceis the first line of every server net event. Why.- Always parameterize SQL.
?placeholders, never string concatenation. Why. - Read a similar resource before writing a new one. Patterns in the wild beat patterns from your head.
- Small commits. One feature at a time. Easier to revert when something breaks.
Most examples target the modern FiveM roleplay stack. If your server differs, adapt - the core concepts stay identical.
| Thing | What we use | Common alternative |
|---|---|---|
| Framework | Qbox (qbx_core) |
QBCore, ESX |
| Inventory | ox_inventory | qb-inventory, tgiann-inventory |
| Targeting | ox_target | qb-target |
| Library | ox_lib | (no real alternative) |
| Database | oxmysql | mysql-async (legacy) |
| Lua runtime | Lua 5.4 | Lua 5.3 |
| Sync | OneSync Infinity | OneSync Legacy |
| NUI framework | React 19 + Vite | Svelte 5, vanilla HTML/JS |
If you're not sure what stack your server uses, check server.cfg for the ensure lines.
Every lesson assumes you have a dev server running. The fastest way to set one up:
- Install txAdmin (it's the recommended FiveM server manager)
- Use the "QBox + ox_lib + ox_inventory" recipe (built-in)
- Start your server, connect from FiveM, and you're in
Workflow:
# edit your code
# save the file
# in-game F8 console:
restart my_resource
# test the change in-game
There's no hot reload for Lua. Restart on every change.
You'll see these words constantly:
| Word | Meaning |
|---|---|
| Resource | A folder with fxmanifest.lua + scripts. The unit of code in FiveM. |
| Native | A function exposed by the GTA V game engine. GetEntityCoords, etc. |
| Event | A named message that scripts fire and listen for. |
| Net event | Event that crosses client↔server. Treat as attack surface. |
| NUI | New UI. The HTML/JS overlay rendered on top of the game. |
| CEF | Chromium Embedded Framework. The browser FiveM uses to render NUI. |
Source / src |
The server ID of the player who triggered an event. |
| citizenid | Stable per-character ID issued by Qbox/QBCore. |
| license | Stable per-player ID. Survives character deletion. |
| Export | A function one resource exposes for others to call. |
| Convar | A server config variable, like mysql_connection_string. |
| State bag | A networked key-value store on an entity or player. |
This repo is MIT licensed (LICENSE) and PR-friendly. If you spot a mistake, an outdated API, or know a better way - open a PR.
See CONTRIBUTING.md for the rules. Short version: keep the tone direct, keep examples runnable, no padding.
Bugs / questions / feature requests: open an issue.
Don't skip. The earliest lessons are the ones every later lesson assumes.
MIT - do whatever you want, just don't sue me. See LICENSE.