-
Notifications
You must be signed in to change notification settings - Fork 0
Home
es_lib is a lightweight module-based utility and UI library for FiveM resources. It provides a lazy-loaded lib global, a client cache, and a set of client/server/shared modules modeled after ox_lib.
- Add to your resource:
shared_script '@es_lib/init.lua'
lua54 'yes'- Use the global
lib:
lib.notify({ type = 'success', description = 'Hello' })- Or call exports directly:
exports.es_lib:notify({ type = 'success', description = 'Hello' })-
lib.name—"es_lib" -
lib.context—"client"or"server" -
lib.cache— cached client data (see below) -
lib.<module>— lazy-loads a module fromimports/<module>/...
Updated every ~100ms.
-
cache.ped— player ped -
cache.playerId— local player ID -
cache.serverId— server ID -
cache.vehicle— current vehicle (0 if none) -
cache.seat— current seat index (-1 if none)
Ensures a module is loaded and returns it.
-
moduleName:string - Returns: module table or function
Loads a resource-local Lua module from the current resource.
-
modulePath: dotted path, e.g."modules.utility.shared.minimap" - Returns: module result or
trueif module returns nil
Returns true when called inside es_lib itself.
Simple readiness check. Always returns true.
-
value:string|nil - Returns:
table|nil(nil on failure)
-
data:table - Returns:
string(JSON or{}on failure)
- Returns:
string|nil
Stores a string value in KVP.
- Returns:
table|nil
Stores a JSON-encoded table.
Deletes a KVP entry.
Fast squared distance.
Squared distance between two vector3s.
Exact distance.
Boolean within radius.
Repeatedly calls cb until it returns a truthy value or times out.
-
timeoutdefaults to1000ms - Returns: the truthy value or
nil
local t = lib.timer(5000, function() print('done') end, true)-
duration: ms -
onEnd: callback -
async: defaulttrue - Returns: Timer instance
Timer methods
timer:pause()-
timer:play()/timer:resume() timer:forceEnd(triggerCallback?)timer:restart()timer:isPaused() -> booleantimer:hasEnded() -> booleantimer:getTimeLeft() -> numbertimer:getTimeLeftFormatted() -> "MM:SS"
data fields:
-
id?,title?,description?,duration?,position? -
type?=info|success|warning|error -
persistent?(sets duration to 0) -
sound?=true(preset) or{ name, set }
Returns: id (if provided)
lib.notifySuccess(msg, title?, sound?)lib.notifyError(...)lib.notifyWarning(...)lib.notifyInfo(...)
lib.progress(data) returns true if completed, false if cancelled.
data:
-
duration,label?,position?(bottom|middle),style?(bar|circle) -
useWhileDead?,canCancel? -
disable?{ move?, car?, combat?, mouse? } -
anim?{ dict?, clip?, scenario?, flag?, blendIn?, blendOut? } -
prop?{ model, bone?, pos?, rot? }
Other progress helpers:
lib.cancelProgress()lib.isProgressActive() -> boolean
lib.requestAnimDict(dict, timeout?) -> booleanlib.requestModel(model, timeout?) -> boolean
local result = lib.alertDialog({
header = 'Confirm',
content = 'Continue?',
cancel = true
})Returns: "confirm" | "cancel"
lib.showTextUI(text, opts?)lib.hideTextUI()
local values = lib.contextMenu({
title = 'Settings',
fields = { ... },
values = { ... },
labels = { confirm = 'OK', cancel = 'Cancel' }
})- Returns: values table or
nil lib.hideContextMenu()
menu:
-
id,title,subtitle?,position? -
disableInput?,canClose? -
options: array of{ label, description?, icon?, iconColor?, progress?, values?, checked?, defaultIndex?, args?, close? } -
onClose?,onSelected?,onSideScroll?,onCheck?
Adds item(s) to the global radial menu.
data:
id-
items: array of{ id, label, icon?, iconColor?, menu?, onSelect?, keepOpen? }
local zone = lib.zones.box({
coords = vector3(...),
size = vector3(...),
rotation = 0,
onEnter = function() end,
onExit = function() end,
inside = function() end,
debug = false
})-
data.points(min 3) -
data.thickness?default4.0 -
onEnter,onExit,inside,debug
-
data.coords,data.size?,data.rotation? -
onEnter,onExit,inside,debug
-
data.coords,data.radius? -
onEnter,onExit,inside,debug
Zone instance methods
zone:remove()-
zone:contains(point)(internal use)
local p = lib.points.new({
coords = vector3(...),
distance = 5.0,
onEnter = function() end,
onExit = function() end,
nearby = function() end
})Point instance methods
point:remove()
Returns: hit, entityHit, endCoords, surfaceNormal, materialHash
Same return as above.
Alias of fromCamera.
Returns: playerId, ped, coords
Returns: vehicle, coords
Returns: array { id, ped, coords }
local lock = lib.disableControls({ move = true, combat = true })
lock:Add('INPUT_JUMP')
lock:Destroy()options:
-
disableMovementormove -
disableCarMovementorcar -
disableCombatorcombat -
disableMouseormouse disableAll
DisableControls instance methods
Add(control)Remove(control)Clear()-
Destroy()/destroy()
items: array of { label, value }
Uses KVP with eslib: prefix.
Command
-
/eslibsettingsopens the settings UI.
lib.callback(name, delay?, cb, ...)lib.callback.await(name, delay?, ...) -> ...lib.callback.register(name, cb)
lib.callback(name, source, cb, ...)lib.callback.await(name, source, ...) -> ...lib.callback.register(name, cb)
Compatibility export:
exports.es_lib:Notify(source, type, message, duration)
These are exports included by es_lib but not lazy-loaded by lib.
exports.es_lib:clearPool(poolName, centerCoords, radius, excludeEntity?)exports.es_lib:clearPools(poolNames, centerCoords, radius, excludeEntity?)exports.es_lib:findNearestInPool(poolName, centerCoords, maxRadius?, excludeEntity?)exports.es_lib:getPed()exports.es_lib:getPlayerId()exports.es_lib:isInVehicle(includeLastVehicle?)exports.es_lib:getCurrentVehicle(includeLastVehicle?)exports.es_lib:getCoords()exports.es_lib:getHeading()exports.es_lib:ensureVehicle(showNotify?)exports.es_lib:getCamDirection()exports.es_lib:copyToClipboard(text)
exports.es_lib:showDebugPanel(payload)exports.es_lib:updateDebugPanel(payload)exports.es_lib:hideDebugPanel()exports.es_lib:isDebugPanelOpen()
payload supports:
-
id,title,subtitle,position,accentColor,lines,data
These are used internally by the callback system and NUI:
es_lib:callbackes_lib:callbackResponsees_lib:clientCallbackes_lib:clientCallbackResponsees_lib:notify
Everest — es_lib