Skip to main content

Getting Started

sure_lib 2.2.1 This guide installs sure_lib into a consuming FiveM resource and loads a first module through the shared loader.

Requirements

Runtime

FiveM with fx_version 'cerulean', game 'gta5', and Lua 5.4 enabled.

Dependencies

ox_lib and es_extended must start before sure_lib.
The db module also expects oxmysql to be available because it calls exports.oxmysql:*_async methods.

Install

1

Place the resource

Put the sure_lib folder in your server resources directory and make sure the folder name is exactly sure_lib.
2

Start dependencies first

Start ox_lib, es_extended, and then sure_lib before resources that consume it.
3

Import the loader

Add the shared loader to each consuming resource.
fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
lua54 'yes'

shared_script '@sure_lib/init.lua'

client_script 'client.lua'
server_script 'server.lua'

dependencies {
  'ox_lib',
  'es_extended',
  'sure_lib'
}
If you use the Lua UI module, point your consuming resource at the bundled renderer.
fxmanifest.lua
ui_page 'https://cfx-nui-sure_lib/web/lui/index.html'
Version 2.2.1 uses @sure_lib/init.lua and sure.getModule(...). Keep consuming resources on this loader shape so examples and module resolution stay consistent.

Load a module

shared.lua
local validator = sure.getModule('validator')

local schema = validator.object({
  name = validator.string().required(),
  amount = validator.integer().min(1)
})

schema.parse({
  name = 'bread',
  amount = 2
})

Common setup checks

Confirm the module name is valid and that you are requesting it from a supported runtime. For example, player, spawn, and lui only exist on the client, while esx and db only exist on the server.
Call sure.player.waitUntilLoaded() before reading player data during resource startup.
Define the cooldown on the server first, then read or start that key from the client.