Anatomy of a resource
A FiveM resource is nothing more than a folder with a label card inside it. The label card is a file called fxmanifest.lua. It tells the server three things: what this folder is, which files belong to it, and which side each file runs on. In this lesson you build that folder by hand, one file at a time, and watch it start.
config.lua is a shared_script, so it loads on both sides; client and server files never cross.Build it, one file at a time
Make the resource folder
Inside your resources folder, make a new folder named exactly:
resources/qu_hello
The folder name is the resource name. Keep it lowercase with no spaces. You type this same name in server.cfg later, so spell it the same everywhere.
Create the manifest file
Inside qu_hello, create a new file named exactly:
fxmanifest.lua
This is the label card. Without it, FiveM ignores the folder. The name must be exactly fxmanifest.lua, not manifest.lua, and not the old __resource.lua.
Write the manifest, line by line
Open fxmanifest.lua and type this. Each line is explained underneath.
fx_version 'cerulean'
game 'gta5'
author 'you'
description 'My first resource'
shared_script 'config.lua'
client_script 'client.lua'
server_script 'server.lua'
fx_version 'cerulean': the manifest format version.ceruleanis the current one.game 'gta5': which game this runs on.gta5is FiveM. (rdr3is RedM.)shared_script: runs on both the server and every client. Use it for config and constants only.client_script: runs on each player's PC. Drawing, key presses, NUI.server_script: runs once on the server. Database, money, anything players must not control.
Create the three script files
Still inside qu_hello, create three more files and put one print in each, so you can see where it runs.
-- config.lua (shared)
print('[qu_hello] shared loaded')
-- client.lua
print('[qu_hello] hello from your CLIENT')
-- server.lua
print('[qu_hello] hello from the SERVER')
Your folder now looks like this:
resources/qu_hello/
fxmanifest.lua
config.lua
client.lua
server.lua
Tell the server to start it
Open your server.cfg file (it sits next to the resources folder). Add this line near the other ensure lines:
ensure qu_hello
ensure means "start this resource, and restart it if it was already running". The name after it must match the folder name exactly.
Restart and read the proof
Save every file. Then, in the live server console (or the txAdmin Live Console, reached from the txAdmin web panel on port 40120), type:
ensure qu_hello
Use ensure. It starts the resource if it is stopped and restarts it if it is already running, so it always works.
Now watch both consoles. The client lines only show once you are in the game world. Join your own server first: open Direct Connect in the FiveM client and connect to 127.0.0.1:30120. Until you are connected, only the two server-console lines appear. That is expected, because there is no client running yet.
The shared line prints on both sides. The server line prints only on the server. The client line prints only on your screen. That split is the whole point of the three script types.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- If something went wrong
- What you can do now
- Try it yourself
The remainder of Anatomy of a resource is available to FiveM School members.