Understanding fxmanifest in RedM and FiveM: A Comprehensive Guide

Published on
5 mins read
--- views
Understanding fxmanifest in RedM and FiveM: A Comprehensive Guide

Introduction

When developing resources for RedM or FiveM, one of the most important files you will work with is the fxmanifest.lua. This file acts as a descriptor for your resource, providing crucial information to the server about your resource's dependencies, scripts, and other metadata. In this article, we'll take an in-depth look at the fxmanifest.lua, its purpose, and how to properly set it up for your RedM or FiveM resource.

What is fxmanifest.lua?

The fxmanifest.lua is a configuration file written in Lua that describes a resource in a RedM or FiveM server. It replaced the previously used __resource.lua file format. The fxmanifest provides a more structured and feature-rich way to define resources.

Every resource must have an fxmanifest.lua file in its root directory. This file contains metadata about the resource, such as its name, version, author, and dependencies. It also specifies the scripts, files, and assets that make up the resource.

Basic Structure

Here's a basic example of an fxmanifest.lua file:

fx_version 'cerulean'
game 'rdr3'

author 'YourName'
description 'A brief description of the resource'
version '1.0.0'

client_scripts {
    'client.lua',
}

server_scripts {
    'server.lua',
}

Let's break down each part:

  • fx_version: Specifies the minimum FiveM version required for the resource to run. We'll discuss the different versions later in this article.
  • game: Indicates the game the resource is intended for. In this case, it's 'rdr3' for RedM. For FiveM, you would use 'gta5'.
  • author, description, and version: Metadata fields that provide information about the resource and its creator.
  • client_scripts and server_scripts: These tables list the client-side and server-side scripts that make up the resource. Scripts listed in client_scripts will run on the player's machine, while those in server_scripts will run on the server.

Script Loading

The fxmanifest.lua allows you to specify the scripts that should be loaded and executed by the client and server. You can list multiple scripts in the client_scripts and server_scripts tables. The scripts will be loaded in the order they are listed.

For example:

client_scripts {
    'utils.lua',
    'main.lua',
    'events.lua',
}

In this case, utils.lua will be loaded first, followed by main.lua and then events.lua on the client-side.

File Loading

In addition to scripts, you can also specify other files that should be included in your resource. These can be config files, HTML files, images, or any other assets your resource needs.

files {
    'config.json',
    'index.html',
    'assets/image.png',
}

The files listed in the files table will be downloaded by clients when they join the server and the resource is started.

Dependencies

If your resource depends on other resources to function properly, you can specify those dependencies in the dependencies table. This ensures that the required resources are loaded before your resource starts.

dependencies {
    'es_extended',
    'mysql-async',
}

In this example, the resource depends on the es_extended and mysql-async resources. The server will ensure these resources are started before starting your resource.

Exports and Imports

Resources can expose functions to other resources through exports. Exports allow resources to share functionality without tightly coupling them.

To export a function, use the exports keyword followed by the function definition:

exports('myFunction', function(arg1, arg2)
    -- Function code here
end)

Other resources can then import and use this exported function:

local myFunction = exports.myResource:myFunction
myFunction(1, 2)

FX Versions

The fx_version field in the fxmanifest.lua specifies the minimum FiveM version required for the resource to run. FiveM uses codenames for its versions, such as adamant, bodacious, and cerulean.

Here's a list of FiveM versions and their corresponding codenames:

  • adamant: FiveM 2425 and above
  • bodacious: FiveM 2189 and above
  • cerulean: FiveM 2372 and above

When specifying the fx_version, use the codename that corresponds to the minimum version your resource requires. For example, if your resource uses features introduced in FiveM 2400, you would set fx_version 'adamant'.

It's important to set the correct fx_version to ensure compatibility and access to the necessary APIs and features provided by FiveM.

Conclusion

The fxmanifest.lua is a critical component of any RedM or FiveM resource. It provides the server with essential information about your resource, its scripts, dependencies, and metadata. By properly configuring your fxmanifest.lua, you ensure that your resource is loaded and executed correctly by the server.

When setting up your fxmanifest.lua, remember to:

  • Specify the correct fx_version based on the minimum FiveM version your resource requires.
  • List all necessary scripts in the client_scripts and server_scripts tables.
  • Include any additional files your resource needs in the files table.
  • Declare dependencies on other resources using the dependencies table.
  • Use exports to share functionality between resources when needed.

By following these guidelines and leveraging tools like the resource manifest generator, you'll be well on your way to creating robust and properly configured resources for your RedM or FiveM server.

Resources

Join Our Community!

Get help, share ideas, get free scripts, and connect with other RedM enthusiasts in our Discord server.

Join Discord