Docs / Trening: skrypty FiveM (GTA V)
Create your first resource
The structure of a FiveM script and a first client / server example in Lua.
Ta dokumentacja jest na razie dostępna tylko po angielsku i francusku.
Training on GTA V: this page covers FiveM, the GTA V roleplay platform. No tool to create a GTA 6 server has been announced: what you learn here is the best preparation.
On FiveM, every feature is a resource: a folder with a manifest and scripts.
1. The structure
resources/
└── [my_scripts]/
└── hello/
├── fxmanifest.lua
├── client.lua
└── server.lua
A folder in square brackets, like [my_scripts], is only for organising: it is not a resource.
2. The manifest
fxmanifest.lua describes the resource:
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
description 'My first resource'
client_script 'client.lua'
server_script 'server.lua'
3. A server script
server.lua: a /hello command that answers in the player's chat.
RegisterCommand('hello', function(source)
TriggerClientEvent('chat:addMessage', source, {
args = { 'Server', 'Hello, welcome to the server!' }
})
end, false)
4. A client script
client.lua: a message when the player spawns.
AddEventHandler('playerSpawned', function()
TriggerEvent('chat:addMessage', { args = { 'Info', 'You are in the city.' } })
end)
5. Start the resource
Add to server.cfg:
ensure hello
Then restart the resource from txAdmin or the console with restart hello.
Golden rules
- Never trust the client: anything that gives money or items must be checked server-side.
- Any player can call a server event: check who calls it and whether it is allowed.
- Measure before optimising: the
resmoncommand in the client console shows what each resource uses.
What about GTA 6?
To be confirmed: the language and functions of GTA 6 scripts are not known. The golden rules above will still apply: check everything server-side and never trust the client. See Prepare your server for GTA 6.
