Skip to content
Ever3st edited this page Feb 1, 2026 · 2 revisions

es_lib — Full API Reference (Everest Ecosystem)

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.

Quick Start

  1. Add to your resource:
shared_script '@es_lib/init.lua'
lua54 'yes'
  1. Use the global lib:
lib.notify({ type = 'success', description = 'Hello' })
  1. Or call exports directly:
exports.es_lib:notify({ type = 'success', description = 'Hello' })

Core Globals & Loader

lib (global)

  • lib.name"es_lib"
  • lib.context"client" or "server"
  • lib.cache — cached client data (see below)
  • lib.<module> — lazy-loads a module from imports/<module>/...

cache (global, client only)

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)

lib.load(moduleName)

Ensures a module is loaded and returns it.

  • moduleName: string
  • Returns: module table or function

lib.require(modulePath)

Loads a resource-local Lua module from the current resource.

  • modulePath: dotted path, e.g. "modules.utility.shared.minimap"
  • Returns: module result or true if module returns nil

lib.isInternalResource()

Returns true when called inside es_lib itself.

exports.es_lib:hasLoaded()

Simple readiness check. Always returns true.


Shared Utilities (lib)

lib.safeJsonDecode(value)

  • value: string|nil
  • Returns: table|nil (nil on failure)

lib.safeJsonEncode(data)

  • data: table
  • Returns: string (JSON or {} on failure)

lib.kvpGet(key, fallback?)

  • Returns: string|nil

lib.kvpSet(key, value)

Stores a string value in KVP.

lib.kvpGetJson(key, fallback?)

  • Returns: table|nil

lib.kvpSetJson(key, data)

Stores a JSON-encoded table.

lib.kvpDelete(key)

Deletes a KVP entry.

lib.distanceSquared(x1,y1,z1,x2,y2,z2)

Fast squared distance.

lib.distanceSquaredVec(v1, v2)

Squared distance between two vector3s.

lib.distance(x1,y1,z1,x2,y2,z2)

Exact distance.

lib.isWithinDistance(x1,y1,z1,x2,y2,z2,radius)

Boolean within radius.

lib.isWithinDistanceVec(v1, v2, radius)

lib.shallowCopy(t)

lib.mergeDefaults(defaults, overrides?)

lib.parseNumber(value, fallback?)

lib.clamp(value, min, max)

lib.round(value, decimals?)

lib.waitFor(cb, errorMessage?, timeout?)

Repeatedly calls cb until it returns a truthy value or times out.

  • timeout defaults to 1000 ms
  • Returns: the truthy value or nil

Timer (lib.timer)

local t = lib.timer(5000, function() print('done') end, true)

lib.timer(duration, onEnd, async?)

  • duration: ms
  • onEnd: callback
  • async: default true
  • Returns: Timer instance

Timer methods

  • timer:pause()
  • timer:play() / timer:resume()
  • timer:forceEnd(triggerCallback?)
  • timer:restart()
  • timer:isPaused() -> boolean
  • timer:hasEnded() -> boolean
  • timer:getTimeLeft() -> number
  • timer:getTimeLeftFormatted() -> "MM:SS"

Notifications & UI (Client)

lib.notify(data|string)

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.hideNotify(id)

lib.clearNotifications()

Convenience

  • lib.notifySuccess(msg, title?, sound?)
  • lib.notifyError(...)
  • lib.notifyWarning(...)
  • lib.notifyInfo(...)

Progress

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

Asset loading

  • lib.requestAnimDict(dict, timeout?) -> boolean
  • lib.requestModel(model, timeout?) -> boolean

Alert Dialog

local result = lib.alertDialog({
  header = 'Confirm',
  content = 'Continue?',
  cancel = true
})

Returns: "confirm" | "cancel"

Text UI

  • lib.showTextUI(text, opts?)
  • lib.hideTextUI()

Context Menu

local values = lib.contextMenu({
  title = 'Settings',
  fields = { ... },
  values = { ... },
  labels = { confirm = 'OK', cancel = 'Cancel' }
})
  • Returns: values table or nil
  • lib.hideContextMenu()

Menu System (Client)

lib.registerMenu(menu, cb?)

menu:

  • id, title, subtitle?, position?
  • disableInput?, canClose?
  • options: array of { label, description?, icon?, iconColor?, progress?, values?, checked?, defaultIndex?, args?, close? }
  • onClose?, onSelected?, onSideScroll?, onCheck?

lib.showMenu(id)

lib.hideMenu(runOnClose?)

lib.getOpenMenu()

lib.setMenuOptions(id, options, index?)


Radial Menu (Client)

lib.addRadialItem(item|items)

Adds item(s) to the global radial menu.

lib.removeRadialItem(id)

lib.clearRadialItems()

lib.registerRadial(data)

data:

  • id
  • items: array of { id, label, icon?, iconColor?, menu?, onSelect?, keepOpen? }

lib.showRadial(menuId?)

lib.hideRadial(skipTransition?)

lib.disableRadial(state)

lib.isRadialOpen() -> boolean

lib.isRadialDisabled() -> boolean

lib.getCurrentRadialId() -> string|nil


Zones (Client)

local zone = lib.zones.box({
  coords = vector3(...),
  size = vector3(...),
  rotation = 0,
  onEnter = function() end,
  onExit = function() end,
  inside = function() end,
  debug = false
})

lib.zones.poly(data)

  • data.points (min 3)
  • data.thickness? default 4.0
  • onEnter, onExit, inside, debug

lib.zones.box(data)

  • data.coords, data.size?, data.rotation?
  • onEnter, onExit, inside, debug

lib.zones.sphere(data)

  • data.coords, data.radius?
  • onEnter, onExit, inside, debug

Zone instance methods

  • zone:remove()
  • zone:contains(point) (internal use)

Points (Client)

local p = lib.points.new({
  coords = vector3(...),
  distance = 5.0,
  onEnter = function() end,
  onExit = function() end,
  nearby = function() end
})

lib.points.new(data)

lib.points.getAllPoints()

lib.points.getNearbyPoints()

lib.points.getClosestPoint()

Point instance methods

  • point:remove()

Raycast (Client)

lib.raycast.fromCoords(coords, destination, flags?, ignore?)

Returns: hit, entityHit, endCoords, surfaceNormal, materialHash

lib.raycast.fromCamera(flags?, ignore?, distance?)

Same return as above.

lib.raycast.cam

Alias of fromCamera.


Entity Getters (Client)

lib.getClosestPlayer(coords, maxDistance?, includePlayer?)

Returns: playerId, ped, coords

lib.getClosestVehicle(coords, maxDistance?, includePlayerVehicle?)

Returns: vehicle, coords

lib.getClosestPed(coords, maxDistance?)

lib.getClosestObject(coords, maxDistance?)

lib.getNearbyPlayers(coords, maxDistance?, includePlayer?)

Returns: array { id, ped, coords }

lib.getNearbyVehicles(coords, maxDistance?, includePlayerVehicle?)

lib.getNearbyPeds(coords, maxDistance?)

lib.getNearbyObjects(coords, maxDistance?)


Disable Controls (Client)

local lock = lib.disableControls({ move = true, combat = true })
lock:Add('INPUT_JUMP')
lock:Destroy()

lib.disableControls(options?) -> DisableControls

options:

  • disableMovement or move
  • disableCarMovement or car
  • disableCombat or combat
  • disableMouse or mouse
  • disableAll

DisableControls instance methods

  • Add(control)
  • Remove(control)
  • Clear()
  • Destroy() / destroy()

Help Bar (Client)

lib.showHelp(items)

items: array of { label, value }

lib.hideHelp()


Settings (Client)

Uses KVP with eslib: prefix.

lib.getSetting(key)

lib.getAllSettings()

lib.openSettingsMenu()

Command

  • /eslibsettings opens the settings UI.

Callback System

Client

  • lib.callback(name, delay?, cb, ...)
  • lib.callback.await(name, delay?, ...) -> ...
  • lib.callback.register(name, cb)

Server

  • lib.callback(name, source, cb, ...)
  • lib.callback.await(name, source, ...) -> ...
  • lib.callback.register(name, cb)

Server Notifications

lib.notify(source, data|string)

lib.notifyAll(data|string)

Compatibility export:

  • exports.es_lib:Notify(source, type, message, duration)

Additional Export-Only Utilities (Client)

These are exports included by es_lib but not lazy-loaded by lib.

Entity / Ped / Camera Helpers

  • 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)

Debug Panel

  • 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

Events (Internal)

These are used internally by the callback system and NUI:

  • es_lib:callback
  • es_lib:callbackResponse
  • es_lib:clientCallback
  • es_lib:clientCallbackResponse
  • es_lib:notify

Clone this wiki locally