Running FXServer

From FiveM
Jump to: navigation, search

FXServer is the next generation of CitizenFX server tooling. This page shows how to run it.

Running from Build Artifacts

  1. Download the latest master branch build for your platform (Windows or Linux/PRoot) from the artifacts server.
  2. Extract the build.
    • Linux: cd path/to/fxs && tar xf fx.tar.xz (you need to have xz installed, on Debian/Ubuntu this is in the xz-utils package)
    • Windows: Use any archiving tool (such as WinRAR or 7-Zip).
  3. Clone cfx-server-data in a new folder (other than your FXServer folder).
  4. Make a server.cfg in your server-data folder. You need to copy the example cfg below into the file.
  5. Run the server from the server-data folder. (cd /d X:\cfx-server-data or cd /home/server/cfx-server-data)
    • Linux: bash /home/server/files/ +exec server.cfg
    • Windows: C:\artifacts\run.cmd +exec server.cfg (from a new cmd window)


  • If you don't get any 'resources found', and it says 'Failed to start resource', you didn't 'cd' to the right folder.
  • If you get a lot of errors about citizen:/scripting/, you didn't use run.cmd.
  • If nothing happens at all except 'sending heartbeat', you didn't use run.cmd and failed to cd to the folder.
  • If no resources get started, and you can't connect, you didn't add +exec.
  • Mono errors (SIGSEGV, exception stack trace) are perfectly fine, and don't signify any error condition.
  • If you get 'Couldn't load resource sessionmanager' then set up IceCon and input 'restart sessionmanager' - Note: I found that this only happens when FXServer has just generated the cache folder, a server restart after having just generated the folder also fixes the error.
  • On windows, you may wish to make a cmd file in the server-data folder with the run code in for ease.

Porting Notes

If you have any more notes, write them here.

Loading Scripts

require doesn't exist anymore, any scripts/libraries should be loaded using the server_script directive in the resource manifest.

For example:

server_script "my_script.lua" -- load script 
server_script "" -- load a particular assembly into the .net appdomain
server_script "@resource_name/script.lua" -- load a script from another resource

To load files at runtime, you can use LOAD_RESOURCE_FILE (LoadResourceFile("resource_name", "file_name")), and for example if it is a Lua file you can use load(...) to load the Lua code, like in the following example:

function loadLuaFile(resource, file)
    return load(LoadResourceFile(resource, file), file)()

String Splitting

str:Split does not exist anymore, you should use the proper Lua functions for this. For the commonly copy-pasted stringsplit function, this'd be:

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    return t

Bitwise Operations

Lua 5.3 deprecated bit32, and the CfxLua runtime does not enable it. Bitwise operations now work using normal operators (&, |, ...) like in most other programming languages.


NeoLua is no longer in use, so the clr namespace does not exist anymore. If you need to run C# code, use the normal .NET runtime and server exports.


If you did any specific bitwise operations assuming during playerConnecting the source value is above 0x10000, this should not be needed anymore to use functions during playerConnecting.


An example server.cfg follows.

# you probably don't want to change these!
# only change them if you're using a server with multiple network interfaces
endpoint_add_tcp ""
endpoint_add_udp ""

start mapmanager
start chat
start spawnmanager
start sessionmanager
start fivem
start hardcap
start rconlog
start scoreboard
start playernames

sv_scriptHookAllowed 1

# change this
#rcon_password yay

sv_hostname "My new FXServer!"

# nested configs!
#exec server_internal.cfg

# loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png

# convars for use from script
set temp_convar "hey world!"

# disable announcing? clear out the master by uncommenting this
#sv_master1 ""

# want to only allow players authenticated with a third-party provider like Steam?
#sv_authMaxVariance 1
#sv_authMinTrust 5

# add system admins
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don't allow quit
add_principal identifier.steam:110000112345678 group.admin # add the admin to the group

# hide player endpoints in external log output
sv_endpointprivacy true

# server slots limit (default to 30)
sv_maxclients 32

For more commands/variables, check cmdlist over rcon. Most commands/set functions can be executed over the command line too, similar to Quake.