Installation
Installation
Download the latest release from the releases page.
Extract the archive into your resources folder.
Add ensure fmLib to your server.cfg.
ensure fmLib # fmLib loads automatically
ensure your-custom-script # Your scripts that use fmLib
Restart your server.
Usage
Basic Setup
In your resource, you need to create an instance of fmLib to access the FM object:
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
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:
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")
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 = {
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:
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:
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:
- Client Adapters - Client-side functions
- Server Adapters - Server-side functions
- Callback Module - Client-server communication
Troubleshooting
FM = exports.fmLib:new() at the top of your lua files.settings.lua.