The structure of a FiveM server
A walkthrough of the folders in a FiveM server: where the binaries live, where your resources go and how they are grouped to keep everything tidy.
Before writing a single line of Lua it helps to understand the lay of the land: how a FiveM server is arranged on the inside. The first time you open the server folder it looks like a mess of files and subfolders, but there are really only three pieces that matter: the binaries that make the server run, the data folder where YOUR server lives, and inside it the resources folder with everything you add. Once you are clear on what each thing is, you will stop being afraid to touch files.
The two halves: the artifact and your data
A FiveM server is built on top of the "artifact" (also called FXServer): the program downloaded from Cfx.re that contains the binaries. That part is NOT touched: you update it by replacing it entirely with a newer version. The other half is your data: your configuration and your resources, which live separately. Keeping them apart is exactly what lets you update the server without losing your work.
C:/FiveM/
├── server/ <- THE ARTIFACT (FXServer binaries)
│ ├── FXServer.exe
│ ├── citizen/
│ └── ... (not edited; replaced when updating)
│
└── txData/ <- YOUR DATA (what is truly yours)
└── CFXDefault_XXXX/ <- profile base folder (created by txAdmin)
├── server.cfg <- server configuration
└── resources/ <- ALL your resources go hereOverview of a FiveM server
txData is the data folder used by txAdmin (the admin panel that ships with the artifact). Inside it, it creates a base folder for each server profile. Your two daily points of interest are server.cfg and resources/: you will rarely touch the rest.
The resources folder: the heart of your server
This is where everything you add lives: scripts, maps, vehicles, interfaces... Each resource is ONE folder with its own fxmanifest.lua (we saw this in the previous chapter). But if you dumped 200 loose resources into resources/ it would be unmanageable. That is why FiveM lets you group resources into folders whose name is wrapped in [brackets].
resources/
├── [local]/ <- GROUP (not a resource)
│ ├── mi_hud/ <- resource (has fxmanifest.lua)
│ └── mi_garaje/ <- resource
│
├── [esx]/ <- GROUP of the framework resources
│ ├── es_extended/
│ ├── esx_menu_default/
│ └── esx_inventory/
│
├── [maps]/ <- GROUP of maps/MLO
│ └── mi_comisaria/
│
└── [standalone]/ <- GROUP of loose resources
└── ox_lib/resources organized by groups
The key point: the [bracketed] folders are NOT resources, they are drawers to group them. They carry no fxmanifest.lua and do not start on their own. Their big advantage is that you can start an entire group at once in server.cfg with a single line.
# Start ALL resources inside [esx] in one go
ensure [esx]
# Or start loose resources one by one
ensure ox_lib
ensure mi_hudensure of a group in server.cfg
You can nest groups: an [esx] can in turn contain an [esx_addons]. FiveM searches for resources recursively inside the brackets, so the hierarchy is only for your own mental order; the real load order is dictated by server.cfg.
Types of resource you will come across
- Scripts (Lua or JavaScript): the server logic. HUD, jobs, economy, commands...
- Maps / MLO: interiors and modifications of the world (a new police station, a custom venue).
- Vehicles: add-on car packs, with their handling .meta and variations.
- NUI (interfaces): menus and interfaces built with HTML/CSS/JS that are displayed over the game.
Many resources need to send files to the player's PC: the 3D model of a car, the textures of a piece of clothing, the .ytd of an object. Those assets that the server "downloads" to the client go in a special folder called stream/. Everything you put inside stream/ is sent automatically to whoever connects, without having to declare it file by file.
[maps]/mi_comisaria/
├── fxmanifest.lua
├── stream/ <- assets that travel to the client
│ ├── comisaria.ydr
│ ├── comisaria.ytd
│ └── comisaria.ybn
└── data/
└── _manifest.ymtA resource with a stream/ folder
Advanced fxmanifest: beyond scripts
The fxmanifest.lua does not only declare client/server scripts. When a resource uses interfaces or game data files, you have to tell it so with specific lines. These are the ones you will see most often:
fx_version 'cerulean'
game 'gta5'
-- Declare files the client must be able to read (they are not scripts)
files {
'html/index.html',
'html/style.css',
'data/vehicles.meta',
}
-- The page shown as the NUI interface
ui_page 'html/index.html'
-- Register a .meta file as game data (vehicles, handling...)
data_file 'VEHICLE_METADATA_FILE' 'data/vehicles.meta'
-- This resource needs another one to start BEFORE it
dependency 'es_extended'
-- Or several dependencies at once
dependencies {
'ox_lib',
'oxmysql',
}Common fxmanifest directives
- files{}: lists the (non-script) files the client needs to be able to load, such as HTML, CSS or .meta.
- ui_page: indicates which HTML is rendered as the NUI interface over the game.
- data_file: registers a .meta as native game data (an add-on car, a handling, etc.).
- dependency / dependencies: force other resources to start first; FiveM complains if any is missing.
Organization best practices
- Group by domain, not on a whim: [esx] for the framework, [maps] for maps, [vehicles] for cars, [local] for your own stuff.
- Lowercase names, no spaces or accents: use underscores (mi_garaje, not "Mi Garaje").
- Separate the configuration: keep a clear config.lua in shared_scripts so you do not have to edit the code.
- One resource, one responsibility: it is better to keep mi_hud and mi_garaje separate than a mega-resource that does everything.
Where do I put a new resource? You drag it into its group's folder (for example [local]) and that is it. If that group already starts with ensure [local] in your server.cfg, FiveM discovers it on its own: there is no need to add a line per resource. If instead you start it loose, you will have to write its ensure mi_recurso by hand. After moving it, a refresh in the server console makes it appear, and ensure mi_recurso turns it on without restarting the whole server.
Typical mistakes you will see on the forums: 1) Putting a resource OUTSIDE resources/ (FiveM will never find it. 2) Naming the folder with uppercase or spaces) the ensure will fail or give odd behavior. 3) Confusing a [group] folder with a resource and trying ensure [maps]/mi_mapa as if the group were part of the name: the resource is called mi_mapa, the brackets only group it.
Put it into practice
Got a question about this? The AI chat knows all of it and answers with code.
Ask the AI