SystemFreaks

How To Build A GTA FiveM Server

How To Build A GTA FiveM Server

What is Grand Theft Auto 5: FiveM

FiveM ( previously known as Five Reborn) is a continuance of FiveM. Custom Grand Theft Auto: 5 Servers, Play on massive servers with full Modding capability, edit your server easily, custom gamemodes, vehicles, and weapons, your world, your choice. The platform allows you to run dedicated functional servers which re-create the complete GTA: Online experience.

 The platform will provide you with the complete GTA:Online experience will also allow you to develop your own understanding even further in using plugins, other maps, and/or scripts. 

Setting up a server

Make sure you have registered a license key on the Cfx.re Keymaster service. You need to have the IP match the public IP on which you’re going to first use the key. Afterwards, the key can be used on any IP, but only on one server at a time.

Windows

Download the server

  1. Download and install Visual C++ Redistributable 2019 or newer.
  2. Go to the artifacts server.
  3. Download the latest recommended build.
  4. Open the server.zip you just downloaded.
  5. Extract it somewhere you want to store it. We’ll pick C:\FXServer\artifact.

  6. Open the folder you just extracted it to. It should look a little like this:

Start the server

  1. Double click FXServer.exe.
  2. This site should open in your browser. Make sure a PIN is filled, and click Link Account.
  3. Log in to your account on Cfx.re in this tab and then click Yes, Allow.
  4. Set a password to log in to your server’s admin page.
  5. Click ‘Next’.
  6. Type a name for your server and click ‘Next’.
  7. Select to use a ‘Popular Template’.
  8. Pick the ‘CFX Default’ template for now. Other templates may exist, but some will require a database server.
  9. Click ‘Save’ or select another path.
  10. Go to the ‘Recipe Deployer’.
  11. Click ‘Next’ once you’re sure the recipe looks fine. It should be fine the way it comes.
  12. Enter the key you just made on the Keymaster in the ‘Before you begin’ step and click ‘Run Recipe’.
  13. If everything’s correct, you can click ‘Next’ again.
  14. … and finally, “Save & Run Server”, and you’re done!

Linux installation steps


Linux

Note that the Linux version of FXServer is only provided as a courtesy port due to issues regarding Linux distribution compatibility and availability of diagnostic tools for native C++ code. If you’re experiencing any issues, you’re more likely to see them fixed if you use the Windows version.

  1. Create a new folder (for example mkdir -p /home/username/FXServer/server), this will be used for the server binaries.
  2. Download the current recommended master branch build for Linux from the artifacts server(copy the URL for the latest server version and use wget <url> to download it).
  3. Extract the build to the directory that was previously created, using cd /home/username/FXServer/server && tar xf fx.tar.xz (you need to have xz installed, on Debian/Ubuntu this is in the xz-utils package).
  4. Clone cfx-server-data in a new folder outside of your server binaries folder.
    4b. For example git clone https://github.com/citizenfx/cfx-server-data.git /home/username/FXServer/server-data
  5. Make a server.cfg file in your server-data folder (copy the example server.cfg file below into that file).
  6. Set the license key in your server.cfg using sv_licenseKey "licenseKeyGoesHere".
  7. Run the server from the server-data folder.
    7b. bash /home/username/FXServer/server/run.sh +exec server.cfg

Common issues

server.cfg

An example server.cfg follows.

# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# These resources will start by default.
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure rconlog

# This allows players to use scripthook-based plugins such as the legacy Lambda Menu.
# Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins.
sv_scriptHookAllowed 0

# Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like rcon_password "YOURPASSWORD"
#rcon_password ""

# A comma-separated list of tags for your server.
# For example:
# - sets tags "drifting, cars, racing"
# Or:
# - sets tags "roleplay, military, tanks"
sets tags "default"

# A valid locale identifier for your server's primary language.
# For example "en-US", "fr-CA", "nl-NL", "de-DE", "en-GB", "pt-BR"
sets locale "root-AQ" 
# please DO replace root-AQ on the line ABOVE with a real language! :)

# Set an optional server info and connecting banner image url.
# Size doesn't matter, any banner sized image will be fine.
#sets banner_detail "https://url.to/image.png"
#sets banner_connecting "https://url.to/image.png"

# Set your server's hostname
sv_hostname "FXServer, but unconfigured"

# Set your server's Project Name
sets sv_projectName "My FXServer Project"

# Set your server's Project Description
sets sv_projectDesc "Default FXServer requiring configuration"

# Nested configs!
#exec server_internal.cfg

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

# convars which can be used in scripts
set temp_convar "hey world!"

# Remove the `#` from the below line if you do not want your server to be listed in the server browser.
# Do not edit it if you *do* want your server listed.
#sv_master1 ""

# 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.fivem:1 group.admin # add the admin to the group

# enable OneSync (required for server-side state awareness)
set onesync on

# Server player slot limit (see https://fivem.net/server-hosting for limits)
sv_maxclients 48

# Steam Web API key, if you want to use Steam authentication (https://steamcommunity.com/dev/apikey)
# -> replace "" with the key
set steam_webApiKey ""

# License key for your server (https://keymaster.fivem.net)
sv_licenseKey changeme

Server Commands

Console commands can be executed either using an RCon tool, directly from the server console interface, a server configuration file, the server command line, or (if a resource is allowed by the ACL) the ExecuteCommand function.

Adding a custom RCon command can be done using the RegisterCommand function on the server, or the (legacy) rconCommand event.

Resource commands

start [resourceName]

Starts the resource specified in the argument, if it was stopped. It is also possible to specify a category name, such as start [cars].

Example:

start lambda-menu
start [cars]

stop [resourceName]

Stops the resource specified in the argument, if it was started. As with start, one can also specify a category name.

Example:

stop mymode

ensure [resourceName]

Restarts the resource specified in the argument, if it was started. If it wasn’t, starts the resource specified in the argument.

As with start and stop, one can also specify a category name.

Example:

ensure my-testing-resource

restart [resourceName]

Restarts the resource specified in the argument, if it was started. Also supports category names.

Example:

restart lambda-menu

refresh

Rescans the resources folder and loads all resource manifests in them, also making new resources available to start using start.

Example:

refresh

Global commands

exec [filename]

Runs the commands specified in the filename. Commonly seen as FXServer.exe +exec server.cfg.

Example:

exec server_nested.cfg

Management commands

status

This is provided by the rconlog resource.

Shows a list of players with their primary identifier, server ID, name, endpoint, and ping.

Example:

status

clientkick [id] [reason]

This is provided by the rconlog resource.

Kicks the client with the specified server ID (as seen in status) from the server, for the stated reason.

Example:

clientkick 43 You're a superstitious idiot!

say [message]

This is provided by the chat resource.

Sends a message in the chat as console.

Example:

say Hi, everybody!

svgui

Opens or closes the server debug GUI.

Configuration variables

onesync [on/off/legacy]

Defines which mode of state awareness to use.

sv_maxClients [newValue]

A console variable that specifies the maximum amount of clients that the server can normally have, as an integer from 1 to 1024.

Values starting at 32 will require onesync to be set to on or legacy, and values above 64 will require onesync to be set to on.

sv_endpointPrivacy [newValue]

A boolean variable that, if true, hides player IP addresses from public reports output by the server.

sv_hostname [newValue]

A string variable that contains the server host name.

sv_authMaxVariance [newValue]

Variance is how likely the user’s id will change for a given provider (i.e. ‘steam’, ‘ip’, or ‘license’).

A console variable as an integer from 1-5 (default 1); from least to most likely to change.

sv_authMinTrust [newValue]

Trust is how unlikely it is for the user’s identity to be spoofed by a malicious client.

A console variable as an integer from 1-5 (default 5); from least to most trustworthy (5 being a method such as external three-way authentication).

load_server_icon [fileName.png]

A console command which loads a specfied icon and sets it as the server icon. The icon needs to be a 96×96 PNG file.

Example:

load_server_icon "my-server.png"

rcon_password [password]

Sets the RCon password. This being unset means RCon is disabled.

steam_webApiKey [key]

Sets a Steam Web API key, which is required to allow for Steam identifiers to be returned by the server.

Access control commands

add_ace [principal] [object] [allow|deny]

Adds an access control entry to the server’s access control list.

Example:

add_ace group.admin command.potato allow
add_ace identifier.steam:110000112345678 command.apple deny

add_principal [child_principal] [parent_principal]

Sets a principal to inherit from another principal.

Example:

# makes identifier.steam:110000112345678 inherit from group.admin
add_principal identifier.steam:110000112345678 group.admin

remove_ace [principal] [object] [allow|deny]

Removes a specified ACE from the server’s access control list.

Example:

remove_ace identifier.steam:110000112345678 command.apple deny

remove_principal [child_principal] [parent_principal]

Removes a specified principal inheritance entry.

Example:

remove_principal identifier.steam:110000112345678 group.admin

test_ace [principal] [object]

Tests if a principal is allowed or denied access to a given object.

Example: test_ace group.admin command.adminstuff

Exit mobile version