RX Scripts Logo
fmLib

Installation

Get started using fmLib within your resources.

Installation

Download the latest release from the releases page.

Extract the archive into your resources folder.

Add ensure fmLib to your server.cfg.

server.cfg
ensure fmLib                # fmLib loads automatically
ensure your-custom-script   # Your scripts that use fmLib
Note: fmLib and frameworks (ESX/QBCore/QBox) use lazy-loading. Start order doesn't matter as they load when needed.

Restart your server.

Usage

Basic Setup

In your resource, you need to create an instance of fmLib to access the FM object:

client.lua
FM = exports.fmLib:new()

-- Now you can use FM functions
if FM.player.isLoggedIn() then
    local job = FM.player.getJob()
    print("Your job:", job.label)
end
server.lua
FM = exports.fmLib:new()

-- Now you can use FM functions
RegisterNetEvent('myScript:doSomething', function()
    local src = source
    local player = FM.player.get(src)
    if player then
        player.addMoney(500, 'bank')
    end
end)

Using in fxmanifest.lua

Add fmLib as a dependency in your resource's manifest:

fxmanifest.lua
fx_version 'cerulean'
game 'gta5'

author 'Your Name'
description 'My Script'
version '1.0.0'

dependency 'fmLib'

client_scripts {
    'client/*.lua'
}

server_scripts {
    'server/*.lua'
}

Using Exports

If you prefer using exports directly without creating an FM instance, all functions are available as exports. The export naming follows this pattern:

Pattern: exports['fmLib']:{category}_{function}

Where:

  • {category} = The adapter category (framework, player, inventory, etc.)
  • {function} = The function name

Why use exports?

  • No need to create FM = exports.fmLib:new() in every file
  • Useful for one-off function calls
  • Can be used in resources where you don't want to initialize fmLib globally

Examples:

-- Client
local job = exports['fmLib']:player_getJob()
exports['fmLib']:framework_notify("Hello!", "success")
local hasItem = exports['fmLib']:framework_hasItem("water")

-- Server
local player = exports['fmLib']:player_get(src)
local balance = exports['fmLib']:account_getMoney("society_police")
exports['fmLib']:framework_notify(src, "Payment received!", "success")
Recommendation: For most use cases, creating the FM instance (FM = exports.fmLib:new()) is cleaner and easier to read. Use exports for quick, one-off calls or when you need minimal integration.

Configuration

Debug Mode

Enable debug mode in settings.lua for verbose logging:

settings.lua
Settings = {
    debug = true,    -- Enable debug messages
    warning = true,  -- Enable warning messages
    useSfx = true,   -- Enable sound effects for web modules
}

Custom Resource Names

If you've renamed any supported resources, update the names in settings.lua:

settings.lua
AdapterResources = {
    framework = {
        esx = 'es_extended',         -- Change if you renamed ESX
        qb = 'qb-core',              -- Change if you renamed QBCore
    },

    inventory = {
        ox = 'ox_inventory',         -- Change if needed
        qb = 'qb-inventory',
        -- ... other inventories
    },

    -- ... other categories
}

Verify Installation

Create a test command to verify fmLib is working:

test.lua
FM = exports.fmLib:new()

-- Client test
RegisterCommand('testfmlib', function()
    if FM then
        FM.framework.notify("fmLib is working!", "success")

        if FM.player.isLoggedIn() then
            local job = FM.player.getJob()
            print("Your job:", job.label)
            print("Your name:", FM.player.getFullName())
        end
    else
        print("fmLib not loaded!")
    end
end)

-- Server test
RegisterCommand('testfmlibserver', function()
    local src = source
    local player = FM.player.get(src)

    if player then
        player.notify("Server fmLib is working!", "success")
        print("Player:", player.getFullName())
        print("Job:", player.getJob().label)
        print("Money:", player.getMoney('bank'))
    else
        print("Failed to get player object")
    end
end)

Migration from v1

If you're migrating from fmLib v1, note that the new adapter system provides:

  • Better performance through lazy loading
  • More consistent API across all resources
  • Automatic resource detection
  • No need to manually configure which resources to use

Old wrapper functions still work but will show deprecation warnings. Update your code to use the new adapter functions:

-- Old (deprecated)
FM.utils.notify(src, "Message", "success")
FM.vehicle.giveKeys(vehicle)

-- New
FM.framework.notify(src, "Message", "success")
FM.keys.give(vehicle)

Next Steps

Now that fmLib is installed, explore the documentation:

Troubleshooting

Make sure you're creating an instance: FM = exports.fmLib:new() at the top of your lua files.
Check the server console for initialization logs. If a resource isn't detected, verify it's running and the name matches in settings.lua.
Some functions only work with specific inventory systems or resources. Check the adapter documentation to see which systems support each function.