<!-- skill: GTA FiveM | version: 1.0.0 | description: Launch FiveM RP servers with txAdmin and Lua | category: Games -->
## Instructions
- Deploy with txAdmin: FXServer latest artifact, txAdmin on :40120, recipe `cfx-server-data`, backup vault on schedule.
- Harden server.cfg: set `sv_hostname`, `sv_maxclients 48`, `sv_licenseKey`, `endpoint_add_tcp/udp`, `sv_authMaxVariance 5`.
- Choose ESX (economy/jobs mature) vs QBCore (modern phone/garages); never mix cores, pin versions + ox_lib dependency.
- Build Lua resources with fxmanifest: `fx_version 'cerulean'`, `game 'gta5'`, client/server/shared scripts, dependency order.
- Use restart workflow: `ensure [resource]` dev, `restart [resource]` hotfix, full `txAdmin restart` for core/DB changes.
- Persist with oxmysql + migrations: players/vehicles/inventory tables, parameterized queries, backup DB hourly.
- Secure server: anti-cheat (screenshot-basic + custom checks), ACE perms for admins, hide DB creds in vault, rate-limit events.
- Validate client events server-side: check job/grade, distance to entity, cooldowns; log to Discord via webhook.
- Stream assets correctly: `stream/` ymaps/ytyps <16MB each, LODs, manifest KVP for interp; test on low VRAM.
- Manage queue + whitelist: connect queue (deferrals), Discord whitelist, ban list with reason + expiry, appeal form.
- Monitor: txAdmin player chart, server thread hitch >100ms alert, crash dump analysis, restart 6h + announcement 10min.
- Monetize fairly: Tebex donations (queue priority, cosmetic cars), no pay-to-win guns per Cfx policy; publish rules.
## Examples
- Example 1 — ESX jobs: police/ambulance/mechanic grades, stash, garage, paycheck every 15min tuned to 800 base.
- Example 2 — QBCore housing: ox_lib zones, owned props, keys shared, persistence via DB + restart-safe state.
- Example 3 — Custom heist: 4-player min-crew check, thermite minigame, cooldown 60min, police alert dispatch event.
## Workflows
1. Install: VPS 4vCPU/8GB, FXServer + txAdmin recipe, link Cfx account, set license key, open 30120/40120 firewall.
2. Core: pick ESX/QBCore, configure server.cfg, connect oxmysql, import SQL, test login + spawn + save.
3. Content: add MLOs/cars (tested stream), jobs, HUD/phone, Discord logs; `ensure` order core->maps->jobs->custom.
4. Launch: whitelist wave 20 players, stress test chase/shootout, fix hitches, publish rules + Tebex live.
5. Operate: daily restarts, ban appeals, weekly updates (1 job or heist), track retention + queue times.
## Templates
### server.cfg essentials
```cfg
sv_hostname "SARAH RP | v1.0 | Whitelisted"
sv_maxclients 48
sv_licenseKey "cfxkey_live_xxxxxxxx"
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
set mysql_connection_string "mysql://fivem:secret@localhost/fivem?charset=utf8mb4"
ensure oxmysql
ensure ox_lib
ensure es_extended
ensure [maps]
ensure sarah_jobs
add_ace group.admin command allow
exec server-perms.cfg
```
### fxmanifest.lua (Lua resource)
```lua
fx_version 'cerulean'
game 'gta5'
author 'SARAH'
description 'Bank heist'
version '1.0.0'
shared_scripts { '@ox_lib/init.lua', 'shared/config.lua' }
client_scripts { 'client/main.lua' }
server_scripts { '@oxmysql/lib/MySQL.lua', 'server/main.lua' }
dependencies { 'ox_lib', 'oxmysql' }
lua54 'yes'
```
### Restart workflow
```
dev loop: edit -> save -> txAdmin console: restart sarah_heist -> test with 2 clients
core change: stop server -> update es_extended -> import migration.sql -> start + smoke login
deploy: git pull -> ensure updated -> watch hitch log 5min -> announce in Discord
```
## Tools
- txAdmin + FXServer artifacts, oxmysql/ox_lib/ox_inventory, ESX or QBCore cores, HeidiSQL/DBeaver.
- Tebex donations, Discord whitelist bot, Git for resources, Sentry crash log relay.
- CodeWalker/OpenIV for MLOs, game build 3095+, server profiler (resmon 1).
## Advanced
- Cut hitches: move loops to server tick 100ms, use state bags for sync, avoid per-frame raycasts on client.
- Scale to 100+: OneSync Infinity, routing buckets per interior, entity lockdown, interest distance tuned 300m.
- Automate ops: watchtx admin events -> Discord, nightly DB dump to S3, artifact update staging before prod.
## Documentation
- https://docs.fivem.net/docs/server-manual/setting-up-a-server/
- https://docs.fivem.net/docs/scripting-manual/runtimes/lua/
- https://github.com/citizenfx/cfx-server-data
- https://overextended.dev/ox_lib/
