DDoS, proxy, and networking basics
Owners ask the same three questions. Why can nobody join. Why does it lag under load. Why am I getting attacked. This lesson gives you the mental model. It also gives you a tiny resource that prints your live networking config, so the numbers stop being abstract. You will not become a network engineer. You will stop guessing and know what to check and what to ask your host.
Build it
We are going to make the networking config concrete. This is a server-only resource. It reads your live network settings and prints them to the console. The ports, the OneSync mode, and the player cap stop being words in a guide and become numbers you can see. Follow the names exactly. Once it prints, the next section takes it apart and explains what each number controls.
Make the resource folder
A resource is a folder of code FiveM loads. Inside your server's resources folder, create this folder:
resources/qu_networking_basics
Create the files
Create this exact file layout:
resources/qu_networking_basics/
fxmanifest.lua
server.lua
Set the endpoints in server.cfg
Open server.cfg. Near the top, where your other networking lines live, declare both endpoints on the same port:
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
set qu_game_port 30120
0.0.0.0 means "listen on every network interface on this machine". 30120 is the port players connect to. The extra qu_game_port line is a convar, a setting outside your code that a script can read. This one is lesson-owned so the probe below can report the number. Keep it equal to the endpoint port. Cfx.re's default config binds both protocols, so allow both through the firewall.
Write fxmanifest.lua
fxmanifest.lua is the manifest file in every resource. It tells FiveM what the resource is and which files to load. Open it and paste this:
fx_version 'cerulean'
game 'gta5'
server_script 'server.lua'
cerulean is the current manifest format version. server_script tells FiveM this file runs on the server, not on players' machines.
Write the lesson code
Open server.lua and paste this:
RegisterCommand('netinfo', function()
local port = GetConvarInt('qu_game_port', 0)
local maxClients = GetConvarInt('sv_maxClients', 48)
local oneSync = GetConvar('onesync', 'off')
print('[qu_networking_basics] game port (TCP+UDP): ' .. port)
print('[qu_networking_basics] txAdmin panel port: check txAdmin host settings (default 40120)')
print('[qu_networking_basics] sv_maxClients: ' .. maxClients)
print('[qu_networking_basics] onesync: ' .. oneSync)
end, true)
Start and test it
Add this line to server.cfg. ensure starts a resource and restarts it if it was already running:
ensure qu_networking_basics
Save, then run this in the txAdmin Live Console:
restart qu_networking_basics
Then run the test command in the same console:
netinfo
Your sv_maxClients and onesync values will be whatever your own server.cfg sets. The point is that they are now readable, not memorized.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- How it works
- If something went wrong
- What you can do now
- Try it yourself
The remainder of DDoS, proxy, and networking basics is available to FiveM School members.