API
Every function, event, key and data shape of more_lib that you can use from your own resource.
more_lib puts ESX and QBCore behind one API: a script calls MORE.GetMoney(...) and the library runs it on whichever framework the server uses. It also brings the shared screen elements (notifications, progress bar, help key, menu, map blips and press-E points) and a set of helper functions. This page lists everything you can call or listen to, grouped by where it runs.
Server functions run in server scripts and client functions in client scripts. A few names exist on both sides with the same meaning, and a few differ: GetPlayerName and GetPlayerIdentifier are server functions, while GetName and GetIdentifier are client functions. Restart the server, or every MORE script after more_lib, when you update the library.
Using more_lib in your own resource
Add more_lib as a dependency of your resource and load its import file, which gives every file the MORE table. Every function on this page can be called as MORE.Name(...) or as exports["more_lib"]:Name(...), and both do the same. Before the framework is ready, calls return nil and print an error: wait for the frameworkLoaded event or check MORE.IsFrameworkLoaded() first. Money accounts always use the neutral keys cash, bank and black, whatever your framework calls them.
| Line in fxmanifest.lua | Where | What it gives you |
|---|---|---|
| @more_lib/backend/imports.lua | shared_script | The MORE table with every function, MORE.Menu, MORE.Cache and the callbacks. You need it to use MORE. |
| @more_lib/backend/shared/openfunctions.lua | shared_script (optional) | The shared helper function GetLang. |
| @more_lib/backend/client/openfunctions.lua | client_script (optional) | The client helper functions. |
| @more_lib/backend/server/openfunctions.lua | server_script (optional) | The server helper functions. |
| dependencies { "more_lib" } | dependencies | Makes sure more_lib starts before your resource. |
Server: players and framework
Functions for the framework, the player and the character on the server. The names differ from the client: GetPlayerName and GetPlayerIdentifier are server functions, while GetName and GetIdentifier are client functions.
| Function | Returns | What it does |
|---|---|---|
| MORE.GetFramework() | "esx" or "qbcore" | The framework that is in use. |
| MORE.IsFrameworkLoaded() | boolean | true once the framework is ready. |
| MORE.GetFrameworkObject() | table | The core object of ESX or QBCore. |
| MORE.GetPlayerData(playerId) | table or nil | The framework's own player object. nil when the player is not loaded. |
| MORE.GetPlayerFromIdentifier(identifier) | table or nil | The framework's player object for an identifier. |
| MORE.GetPlayerIdentifier(playerId) | string | ESX: the license. QBCore: the citizen id. |
| MORE.GetPlayerName(playerId) | string | The character name. |
| MORE.GetPlayers() | number[] | The server ids of all loaded players. |
| MORE.GetCharInfo(playerId) | PlayerCharInfo | The character sheet: name, gender, birth date and phone (see Data shapes). |
| MORE.GetPlayerMetadata(playerId, key) | any | The stored value. |
| MORE.SetPlayerMetadata(playerId, key, value) | boolean | Stores a value. |
| MORE.IsPlayerDead(playerId) | boolean | true while that player's own client reports that the player is down. |
Server: jobs, groups and money
The accounts are the neutral keys cash, bank and black. MS.Accounts in config.lua maps them to the account names of your framework.
| Function | Returns | What it does |
|---|---|---|
| MORE.GetJob(playerId) | PlayerJob | The player's job (see Data shapes). |
| MORE.GetJobs() | JobList[] | Every job of the framework, by name, with the label of each grade. |
| MORE.SetJob(playerId, name, grade) | boolean | Sets the player's job and grade. |
| MORE.GetGroup(playerId) | string | The permission group, for example admin. On QBCore, when the core reports no group, the ACE groups in MS.Permissions are checked in order. |
| MORE.GetMoney(playerId, account) | number | The balance of cash, bank or black. |
| MORE.AddMoney(playerId, account, amount) | boolean | Adds money to the account. |
| MORE.RemoveMoney(playerId, account, amount) | boolean | Removes money. false when the player can't pay it. |
Server: items and weapons
When ox_inventory runs (see MS.Settings.inventory), all item calls go through it automatically. Weapon names use the game's name, for example WEAPON_PISTOL.
| Function | Returns | What it does |
|---|---|---|
| MORE.GetItem(playerId, name) | PlayerItem | The item of the player. count is 0 when the player has none. |
| MORE.AddItem(playerId, name, count, metadata?) | boolean | Gives items. Only QBCore and ox_inventory use the metadata. |
| MORE.RemoveItem(playerId, name, count) | boolean | Takes items. false when the player doesn't have that many. |
| MORE.CanCarryItem(playerId, name, count) | boolean | Whether the player can carry that many. |
| MORE.GetInventory(playerId) | PlayerItem[] | Every item of the player. |
| MORE.RegisterUsableItem(name, function(playerId) end) | nothing | Runs your function when a player uses the item. It uses the usable item list of ESX or QBCore. |
| MORE.GetWeapon(playerId, weaponName) | PlayerWeapon or nil | The weapon of the player, or nil. |
| MORE.HasWeapon(playerId, weaponName) | boolean | Whether the player has the weapon. |
| MORE.AddWeapon(playerId, weaponName, ammo?) | boolean | Gives a weapon. |
| MORE.RemoveWeapon(playerId, weaponName) | boolean | Takes a weapon. |
| MORE.AddWeaponTint(playerId, weaponName, tintIndex) | boolean | ESX only. Always false on QBCore. |
| MORE.AddWeaponComponent(playerId, weaponName, component) | boolean | ESX only. Always false on QBCore. |
Server: callbacks, notifications and product registration
MORE carries its own server callbacks, the same on every framework. Your function always runs once: with the answer, or with nothing when the server callback failed.
| Function | Returns | What it does |
|---|---|---|
| MORE.RegisterServerCallback(name, function(playerId, cb, ...) end) | nothing | Registers a callback that a client asks with TriggerServerCallback. cb answers once, and later calls do nothing. If your function throws an error, the error is printed in the server console and the client gets an answer with nothing in it. Registering a name again replaces the function. |
| MORE.Notify(playerId, type, title, message, time) | nothing | Shows a notification. type is success, error or info. It uses more_hud when that is started, otherwise esx:showNotification. |
| MORE.RegisterProduct(id, version) | nothing | Registers a resource for the update check, with an id of letters, digits and underscores (at most 64) and a version like 1.2.3. MORE scripts call this themselves. With MS.Telemetry set to false nothing is sent. |
Client: player and framework
Call these once the player is loaded: check MORE.IsPlayerLoaded(), or call WaitForPlayer() from a thread. MORE.Cache holds the player's own ped (MORE.Cache.ped), the vehicle the player sits in (MORE.Cache.vehicle, false on foot), the seat (MORE.Cache.seat, -1 is the driver's seat and false on foot) and the selected weapon's hash (MORE.Cache.weapon). It can lag up to 500 ms behind the game, and the event more_lib::client:cache reports each change.
| Function | Returns | What it does |
|---|---|---|
| MORE.GetFramework() | "esx" or "qbcore" | The framework that is in use. |
| MORE.IsFrameworkLoaded() | boolean | true once the framework is ready. |
| MORE.GetFrameworkObject() | table | The core object of the framework. |
| MORE.IsPlayerLoaded() | boolean | true once the player's character is loaded. |
| MORE.GetPlayerData() | table | The framework's own player data. |
| MORE.GetIdentifier() | string | ESX: the license. QBCore: the citizen id. |
| MORE.GetName() | string | The character name. |
| MORE.GetJob() | PlayerJob | The player's job. |
| MORE.GetGroup() | string | The permission group. |
| MORE.GetMoney(account) | number | The balance of cash, bank or black. |
| MORE.GetItem(name) | PlayerItem | The item of the player. count is 0 when the player has none. |
| MORE.HasItem(name, count?) | boolean | Whether the player has that many. count defaults to 1. |
| MORE.GetInventory() | PlayerItem[] | Every item of the player. |
| MORE.IsPlayerDead(serverId?) | boolean | With no argument it checks your own player. |
| MORE.GetWeaponData(hash?) | WeaponData or nil | The weapon in the player's hand, or the one of the hash: name, label, clip, clipSize and reserve. nil for a weapon that MS.Weapons does not list, and for bare hands. |
| MORE.GetFont() | number | The font id for SetTextFont, taken from MS.Settings.font. |
| MORE.Cache | table | ped, vehicle, seat and weapon, as described above. |
Client: callbacks, notifications, and screen
Notifications, the progress bar and the help key are drawn by the library. When the game's pause menu is open, they are hidden.
| Function | Returns | What it does |
|---|---|---|
| MORE.TriggerServerCallback(name, function(...) end, ...) | nothing | Asks a server callback. Your function runs once: with the server's answer, or with nothing when the server callback failed or gave no answer within 60 seconds. |
| MORE.AwaitServerCallback(name, ...) | the answer | The same in one line: waits for the answer, or gets nothing. Call it from a thread. |
| MORE.RegisterClientCallback(name, function(cb, ...) end) | nothing | Registers a client callback through the callback API of your framework. It needs a framework version that has one. |
| MORE.Notify(type, title, message, time?) | nothing | Shows a notification. type is success, error or info. time defaults to 5000 ms. |
| MORE.Progressbar(time, label?) | nothing | Shows the progress bar for time ms. |
| MORE.HideProgressbar() | nothing | Hides the progress bar. |
| MORE.HelpKey(key, text) | nothing | Shows a prompt such as [E] Open the shop. You can call it every frame. |
| MORE.HideHelpKey() | nothing | Hides the prompt. |
| MORE.FadeOut(ms) | nothing | Two black panels slide in from the sides over ms and meet in the middle, then the MORE logo flies in between them. It returns once they have met and the screen is black, and at once while it already is. If your resource stops while the screen is covered, it opens again. |
| MORE.FadeIn(ms) | nothing | The logo stays at least until it has landed and leaves, then the panels slide apart over ms. It returns at once. |
Menus
A GTA-style menu drawn by the library. It takes no mouse focus, so the player can keep walking or driving while it is open. Players move with the arrow keys (hold to scroll), select with Enter and go back with Backspace, and can rebind these under Settings, Key Bindings, FiveM. Only one menu shows at a time: when another resource opens its menu, it replaces yours, and Backspace goes back to the one before. Restarting your resource closes its menu. Changes made with Set show up immediately.
| Function | Returns | What it does |
|---|---|---|
| MORE.Menu.new(title?, subtitle?, position?, width?, maxVisibleItems?, banner?) | menu | Creates a menu. The options are listed in the next section. |
| menu:AddButton(label, rightLabel?, description?, badges?, disabled?) | item | A button. Use :OnClick(function(item) end) for the click. |
| menu:AddCheckbox(label, description?, badges?, checked?, disabled?) | item | A checkbox. Use :OnCheck(function(item, checked) end). |
| menu:AddList(label, description?, badges?, values, current?, disabled?) | item | A list of values. current is the position in values (1 is the first). Use :OnChange(function(item, index) end). |
| menu:AddSlider(label, description?, badges?, max, min?, step?, current?, disabled?) | item | A slider. min defaults to 0, step to 1 and current to min. Use :OnChange(function(item, value) end). |
| menu:AddSeparator(label) | item | A line of text. The cursor skips separators and disabled items. |
| menu:Open() | nothing | Shows the menu on top of the open ones. |
| menu:Close() | nothing | Goes back one menu. |
| MORE.Menu.CloseAll() | nothing | Closes all your menus. |
| menu:IsOpen() | boolean | true while this menu is the one on screen. |
| menu:Clear() | nothing | Removes all items, so you can rebuild the menu, even while it is open. |
| menu:Set(key, value) | nothing | Changes title, subtitle, position, width, maxVisibleItems or banner. |
| item:Set(key, value) | nothing | Changes label, rightLabel, description, badges, disabled, checked, values, current, min, max or step. |
Menu options
The optional parameters of MORE.Menu.new, in this order: title, subtitle, position, width, maxVisibleItems and banner.
| Option | Default | Values |
|---|---|---|
| position | top-left | top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center or bottom-right. |
| width | 432 | Pixels at 1920 by 1080. |
| maxVisibleItems | 10 | Rows shown before the list scrolls. |
| banner | none | The URL of an image that shows behind the title. |
Menu text colours and badges
Colours work in any menu text: ~r~ red, ~g~ green, ~b~ blue, ~y~ yellow, ~o~ orange, ~p~ purple, ~q~ pink, ~c~ grey, ~m~ dark grey, ~u~ black and ~w~ white, and ~s~ resets. Badges are icons at the start or end of a row, written as badges = { left = "shop_lock", right = "arrowright" }. Use arrowright on a button that opens a submenu. The available names are arrowleft, arrowright, card_suit_clubs, card_suit_diamonds, card_suit_hearts, card_suit_spades, medal_bronze, medal_gold, medal_silver, mp_alerttriangle, mp_hostcrown, mp_medal_bronze, mp_medal_gold, mp_medal_silver, mp_specitem_cash, mp_specitem_coke, mp_specitem_heroin, mp_specitem_meth, mp_specitem_weed, shop_ammo_icon, shop_armour_icon, shop_art_icon, shop_barber_icon, shop_box_blank, shop_box_cross, shop_box_tick, shop_chips, shop_clothing_icon, shop_franklin_icon, shop_garage_bike_icon, shop_garage_icon, shop_gunclub_icon, shop_health_icon, shop_lock, shop_lock_arena, shop_makeup_icon, shop_mask_icon, shop_michael_icon, shop_new_star, shop_tattoos_icon and shop_trevor_icon.
World points: AddInteraction and RemoveInteraction
A press-E point in the world, drawn by the library: a dot over it while the player is near and looks at it, and the Interact key (E by default) for the closest point in range. One proximity loop serves every resource. Adding an id again replaces the point, and restarting your resource removes its points. Each different image URL keeps a hidden browser open in the player's game until more_lib stops, so use one picture for many points. Put your own checks (job, vehicle, dead) and MORE.HelpKey in enter, exit and pressed. A point with invalid options is ignored and an error is printed.
| Function or option | Value | What it does |
|---|---|---|
| MORE.AddInteraction(id, options) | nothing | Adds a point, or replaces the one with the same id. The id is a string or a number. |
| MORE.RemoveInteraction(id) | nothing | Removes the point. |
| coords | vector3 or vector4 | Where the point is: at floor level or where a player stands. The dot floats 1 m above the floor either way. |
| showDist | number, required | Metres within which enter fires and the dot shows. exit fires on the way out. |
| interactDist | number, required with pressed | Metres within which the Interact key calls pressed. |
| enter, exit, pressed | functions, optional | pressed fires for the closest point in range while the player looks at it. |
| marker | table, optional | { type?, image?, scale?, color? }, drawn at the dot's height while MS.Interaction is false. image is a picture's URL (a transparent PNG), shown upright and turned to the camera in a square scale.x metres wide. Without it, type is the GTA marker to draw. scale is a vector3 (default 0.5) and color is { r, g, b, a } (default white, half transparent on a GTA marker). |
| ped | table, optional | { model, heading }: a ped that stands on the point while MS.Interaction is false. |
Map blips: AddBlip and RemoveBlip
A blip on the map. Adding an id again replaces the blip. A script's blips go away when that script stops, and come back when more_lib restarts.
| Function or option | Value | What it does |
|---|---|---|
| MORE.AddBlip(id, options) | nothing | Adds a blip, or replaces the one with the same id. |
| MORE.RemoveBlip(id) | nothing | Removes the blip. |
| coords | vector3 | Where the blip is. |
| sprite | number | The game's blip sprite. |
| color | number | The game's blip colour. |
| scale | number | The size of the blip. |
| label | string | The name of the blip, already translated. |
| display | number, optional | The game's blip display. Defaults to 4. |
| shortRange | boolean, optional | Defaults to true. |
| info | table, optional | { title, image, rows }: the card that the pause map shows while the cursor is on the blip. title is translated, image is a picture's URL (cropped to 16:9) and rows is a list of { left, right? }. |
Client helper functions
Plain functions that you call without MORE. Add @more_lib/backend/client/openfunctions.lua to your client_scripts to use them.
| Function | Returns | What it does |
|---|---|---|
| DrawText3D(coords, text, scale?, r?, g?, b?) | nothing | Draws text at a world position in the configured font. Call it every frame. scale defaults to 0.35 and the colour to white. |
| DrawTextOnScreen(text, scale, color, pos) | nothing | Draws centred text on the screen. scale is a vector2, color is { r, g, b, a } and pos is a vector2. |
| LoadModel(model) | hash or nil | Loads a model. nil when it is missing or not loaded within 5 seconds. |
| LoadAnimDict(dict) | boolean | Loads an animation dictionary. |
| LoadAsset(requestNative, hasLoadedNative, asset) | boolean | Loads any other asset, for example LoadAsset(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, "core"). |
| PlayAnim(dict, name, flag?, duration?) | boolean | Loads the dictionary and plays the animation on the player. duration is in ms. |
| SpawnObject(model, coords, heading?, networked?) | handle or nil | Creates an object. It is local unless networked is true. |
| SpawnVehicle(model, coords, heading?, networked?) | handle or nil | Creates a vehicle. It is networked by default. |
| RemoveEntity(entity) | nothing | Deletes an object, vehicle or ped that your client owns. |
| Teleport(coords, heading?) | nothing | Teleports the player with the vehicle, out of sight: the screen fades out before and back in after, unless it is already faded out. With z set to 0.0 it finds the ground height. |
| GetWaypointCoords() | vector3 or nil | The map waypoint, or nil when none is set. |
| GetClosestPlayer(coords, radius) | player index, distance | The closest player. The distance is -1 when nobody is near. It skips yourself. |
| GetPlayersInArea(coords, radius) | number[] | The player indices within the radius. It skips yourself. |
| GetClosestVehicle(coords, radius) | vehicle, distance | The closest vehicle. The vehicle is 0 when none is near. |
| GetClosestObject(coords, radius) | object, distance | The closest object. The object is 0 when none is near. |
| GetClosestPed(coords, radius) | ped, distance | The closest ped. |
| GetClosestEntity(pool, coords, radius, ignore?) | entity, distance | The same for the pool CObject, CVehicle or CPed. |
| GetVehiclePlate(vehicle) | string | The plate without padding spaces. |
| GetVehicleLabel(model) | string | The display name, for example Adder. |
| GetVehicleMaxSpeed(vehicle) | number | The estimated top speed in km/h. |
| IsVehicleEmpty(vehicle) | boolean | true when nobody sits in it. |
| GetVehicleFuel(vehicle) | number | The fuel level, 0 to 100. |
| SetVehicleFuel(vehicle, fuel) | boolean | Sets the fuel level, 0 to 100. false when the vehicle is networked and you don't control it. |
| UpdateGamerTag(tag, playerIndex) | nothing | Styles an overhead name tag. |
| RemoveGamerTags(tags) | nothing | Removes overhead name tags. |
| WaitForPlayer() | nothing | Waits until the session, the framework and the player are loaded. Call it from a thread. |
| GetLocaleStrings() | table | Your MS.Locales[MS.Locale] over MS.Locales["en"], as one table for your NUI. |
| GetBoundKey(command, default) | string | The key the player bound a RegisterKeyMapping command to, for example G. It returns default for a key without a plain name, such as a mouse button. |
| RaycastFromCamera(distance, flags, ignore?) | hit, coords, normal, entity | A ray from the camera along its view. The entity is 0 for the world. |
Shared and server helper functions
GetLang is a shared function, and the others are server functions. Add @more_lib/backend/shared/openfunctions.lua to your shared_scripts, and @more_lib/backend/server/openfunctions.lua to your server_scripts.
| Function | Returns | What it does |
|---|---|---|
| GetLang(key, ...) | string | Your text for key: MS.Locales[MS.Locale], then MS.Locales["en"], then the key itself. Extra arguments fill %s and %d. |
| GetLimitedText(value, limit) | string or nil | Trims text from a client and cuts it to limit bytes. nil when nothing is left. |
| CheckCooldown(store, playerId, seconds) | boolean, seconds left | true when the player may act again. Otherwise false and the seconds left. |
| IsNearCoords(playerId, coords, maxDistance) | boolean | Checks the player's position on the server. |
| IsNearAny(playerId, points, maxDistance) | boolean | The same for a list of points. |
| IsNearEntity(playerId, entity, maxDistance) | boolean | The same for an entity. |
| GetPlayersInArea(coords, radius, ignore?) | number[] | The server ids within the radius. |
| GetClosestPlayer(coords, radius, ignore?) | server id, distance | The closest server id. nil when nobody is near. |
| SendToPlayers(players, eventName, ...) | nothing | Sends a client event to a list of server ids. |
| WaitForNetworkEntity(netId) | entity or nil | Waits up to 5 seconds for a networked entity to exist. |
| SpawnVehicle(model, coords, heading?, vehicleType?) | entity or nil | Creates a networked vehicle on the server. |
| DecodeJson(text, default) | any | Reads a JSON column. Returns default when the text is not valid. |
| EncodeVector(coords) | string | Stores a vector3 as JSON for a column. |
| DecodeVector(text, default?) | vector3 or nil | Reads a vector3 back from a JSON column. |
| FormatDateTime(timestamp?) | string | YYYY-MM-DD HH:MM:SS, for a DATETIME column. |
| StartInterval(ms, fn) | nothing | Runs fn every ms milliseconds. An error is printed and the next run still happens. |
| SendWebhook(settings, embed) | boolean | Sends a Discord embed. settings needs enabled and webhook, and can have username, avatar and color. |
Events
Listen with AddEventHandler on the same side. The framework events are the same on ESX and QBCore.
| Event | Arguments | When it fires |
|---|---|---|
| more_lib::server:frameworkLoaded | frameworkName | The framework is ready on the server. |
| more_lib::server:playerLoaded | playerId, playerObject | A player's character has loaded. |
| more_lib::server:playerDropped | playerId | A loaded player left. |
| more_lib::server:setJob | playerId, job, lastJob | A player's job changed. lastJob is given on ESX only. |
| more_lib::client:frameworkLoaded | frameworkName | The framework is ready on the client. |
| more_lib::client:playerLoaded | playerData | Your character has loaded. |
| more_lib::client:playerUnloaded | none | Your character was unloaded. |
| more_lib::client:setJob | job | Your job changed. |
| more_lib::client:setGroup | group | Your group changed. ESX only. |
| more_lib::client:setMoney | account, amount | An account balance changed. |
| more_lib::client:addItem | name, count | An item was added. count is the new total. |
| more_lib::client:removeItem | name, count | An item was removed. count is the new total. |
| more_lib::client:playerDied | none | The player went down (see MS.Death). |
| more_lib::client:playerRevived | none | The player was revived. |
| more_lib::client:cache | changed fields | Only the MORE.Cache fields that changed, for example { vehicle = false } when the player gets out. |
| more_lib::client:pauseMenu | active | The game's pause menu opened (true) or closed (false). While it is open the library hides its own screen elements. |
Data shapes
These tables look the same on ESX and QBCore.
| Shape | Fields | Notes |
|---|---|---|
| PlayerJob | name, label, grade, gradeName, gradeLabel, salary, onDuty | onDuty is always true on ESX. |
| JobList | name, label, grades | grades[grade + 1] is the label of that grade, and an empty text for a grade the job lacks. |
| PlayerItem | name, label, count, metadata? | count is 0 when the player has none. |
| PlayerCharInfo | firstName, lastName, gender, birthDate?, phone | gender is male or female. phone is empty when the player has no phone. |
| PlayerWeapon | name, label, ammo, components, tintIndex | Returned by GetWeapon. |
| WeaponData | name, label, clip, clipSize, reserve | Returned by the client function GetWeaponData. clipSize includes extended magazines. |
Keys the library registers
These are normal FiveM key mappings. Players can rebind them under Settings, Key Bindings, FiveM.
| Name in Key Bindings | Default key | What it does |
|---|---|---|
| Interact | E | Uses the closest world point in range (command more_interact). |
| Menu up, Menu down, Menu left, Menu right | Arrow keys | Move in the open menu. Hold to scroll. |
| Menu select | Enter | Selects the highlighted row. |
| Menu back | Backspace | Goes back one menu. |
Last updated