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.luaWhereWhat it gives you
@more_lib/backend/imports.luashared_scriptThe MORE table with every function, MORE.Menu, MORE.Cache and the callbacks. You need it to use MORE.
@more_lib/backend/shared/openfunctions.luashared_script (optional)The shared helper function GetLang.
@more_lib/backend/client/openfunctions.luaclient_script (optional)The client helper functions.
@more_lib/backend/server/openfunctions.luaserver_script (optional)The server helper functions.
dependencies { "more_lib" }dependenciesMakes 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.

FunctionReturnsWhat it does
MORE.GetFramework()"esx" or "qbcore"The framework that is in use.
MORE.IsFrameworkLoaded()booleantrue once the framework is ready.
MORE.GetFrameworkObject()tableThe core object of ESX or QBCore.
MORE.GetPlayerData(playerId)table or nilThe framework's own player object. nil when the player is not loaded.
MORE.GetPlayerFromIdentifier(identifier)table or nilThe framework's player object for an identifier.
MORE.GetPlayerIdentifier(playerId)stringESX: the license. QBCore: the citizen id.
MORE.GetPlayerName(playerId)stringThe character name.
MORE.GetPlayers()number[]The server ids of all loaded players.
MORE.GetCharInfo(playerId)PlayerCharInfoThe character sheet: name, gender, birth date and phone (see Data shapes).
MORE.GetPlayerMetadata(playerId, key)anyThe stored value.
MORE.SetPlayerMetadata(playerId, key, value)booleanStores a value.
MORE.IsPlayerDead(playerId)booleantrue 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.

FunctionReturnsWhat it does
MORE.GetJob(playerId)PlayerJobThe 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)booleanSets the player's job and grade.
MORE.GetGroup(playerId)stringThe 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)numberThe balance of cash, bank or black.
MORE.AddMoney(playerId, account, amount)booleanAdds money to the account.
MORE.RemoveMoney(playerId, account, amount)booleanRemoves 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.

FunctionReturnsWhat it does
MORE.GetItem(playerId, name)PlayerItemThe item of the player. count is 0 when the player has none.
MORE.AddItem(playerId, name, count, metadata?)booleanGives items. Only QBCore and ox_inventory use the metadata.
MORE.RemoveItem(playerId, name, count)booleanTakes items. false when the player doesn't have that many.
MORE.CanCarryItem(playerId, name, count)booleanWhether the player can carry that many.
MORE.GetInventory(playerId)PlayerItem[]Every item of the player.
MORE.RegisterUsableItem(name, function(playerId) end)nothingRuns your function when a player uses the item. It uses the usable item list of ESX or QBCore.
MORE.GetWeapon(playerId, weaponName)PlayerWeapon or nilThe weapon of the player, or nil.
MORE.HasWeapon(playerId, weaponName)booleanWhether the player has the weapon.
MORE.AddWeapon(playerId, weaponName, ammo?)booleanGives a weapon.
MORE.RemoveWeapon(playerId, weaponName)booleanTakes a weapon.
MORE.AddWeaponTint(playerId, weaponName, tintIndex)booleanESX only. Always false on QBCore.
MORE.AddWeaponComponent(playerId, weaponName, component)booleanESX 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.

FunctionReturnsWhat it does
MORE.RegisterServerCallback(name, function(playerId, cb, ...) end)nothingRegisters 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)nothingShows a notification. type is success, error or info. It uses more_hud when that is started, otherwise esx:showNotification.
MORE.RegisterProduct(id, version)nothingRegisters 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.

FunctionReturnsWhat it does
MORE.GetFramework()"esx" or "qbcore"The framework that is in use.
MORE.IsFrameworkLoaded()booleantrue once the framework is ready.
MORE.GetFrameworkObject()tableThe core object of the framework.
MORE.IsPlayerLoaded()booleantrue once the player's character is loaded.
MORE.GetPlayerData()tableThe framework's own player data.
MORE.GetIdentifier()stringESX: the license. QBCore: the citizen id.
MORE.GetName()stringThe character name.
MORE.GetJob()PlayerJobThe player's job.
MORE.GetGroup()stringThe permission group.
MORE.GetMoney(account)numberThe balance of cash, bank or black.
MORE.GetItem(name)PlayerItemThe item of the player. count is 0 when the player has none.
MORE.HasItem(name, count?)booleanWhether the player has that many. count defaults to 1.
MORE.GetInventory()PlayerItem[]Every item of the player.
MORE.IsPlayerDead(serverId?)booleanWith no argument it checks your own player.
MORE.GetWeaponData(hash?)WeaponData or nilThe 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()numberThe font id for SetTextFont, taken from MS.Settings.font.
MORE.Cachetableped, 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.

FunctionReturnsWhat it does
MORE.TriggerServerCallback(name, function(...) end, ...)nothingAsks 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 answerThe same in one line: waits for the answer, or gets nothing. Call it from a thread.
MORE.RegisterClientCallback(name, function(cb, ...) end)nothingRegisters a client callback through the callback API of your framework. It needs a framework version that has one.
MORE.Notify(type, title, message, time?)nothingShows a notification. type is success, error or info. time defaults to 5000 ms.
MORE.Progressbar(time, label?)nothingShows the progress bar for time ms.
MORE.HideProgressbar()nothingHides the progress bar.
MORE.HelpKey(key, text)nothingShows a prompt such as [E] Open the shop. You can call it every frame.
MORE.HideHelpKey()nothingHides the prompt.
MORE.FadeOut(ms)nothingTwo 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)nothingThe logo stays at least until it has landed and leaves, then the panels slide apart over ms. It returns at once.

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.

FunctionReturnsWhat it does
MORE.Menu.new(title?, subtitle?, position?, width?, maxVisibleItems?, banner?)menuCreates a menu. The options are listed in the next section.
menu:AddButton(label, rightLabel?, description?, badges?, disabled?)itemA button. Use :OnClick(function(item) end) for the click.
menu:AddCheckbox(label, description?, badges?, checked?, disabled?)itemA checkbox. Use :OnCheck(function(item, checked) end).
menu:AddList(label, description?, badges?, values, current?, disabled?)itemA 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?)itemA slider. min defaults to 0, step to 1 and current to min. Use :OnChange(function(item, value) end).
menu:AddSeparator(label)itemA line of text. The cursor skips separators and disabled items.
menu:Open()nothingShows the menu on top of the open ones.
menu:Close()nothingGoes back one menu.
MORE.Menu.CloseAll()nothingCloses all your menus.
menu:IsOpen()booleantrue while this menu is the one on screen.
menu:Clear()nothingRemoves all items, so you can rebuild the menu, even while it is open.
menu:Set(key, value)nothingChanges title, subtitle, position, width, maxVisibleItems or banner.
item:Set(key, value)nothingChanges label, rightLabel, description, badges, disabled, checked, values, current, min, max or step.

The optional parameters of MORE.Menu.new, in this order: title, subtitle, position, width, maxVisibleItems and banner.

OptionDefaultValues
positiontop-lefttop-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center or bottom-right.
width432Pixels at 1920 by 1080.
maxVisibleItems10Rows shown before the list scrolls.
bannernoneThe URL of an image that shows behind the title.

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 optionValueWhat it does
MORE.AddInteraction(id, options)nothingAdds a point, or replaces the one with the same id. The id is a string or a number.
MORE.RemoveInteraction(id)nothingRemoves the point.
coordsvector3 or vector4Where the point is: at floor level or where a player stands. The dot floats 1 m above the floor either way.
showDistnumber, requiredMetres within which enter fires and the dot shows. exit fires on the way out.
interactDistnumber, required with pressedMetres within which the Interact key calls pressed.
enter, exit, pressedfunctions, optionalpressed fires for the closest point in range while the player looks at it.
markertable, 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).
pedtable, 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 optionValueWhat it does
MORE.AddBlip(id, options)nothingAdds a blip, or replaces the one with the same id.
MORE.RemoveBlip(id)nothingRemoves the blip.
coordsvector3Where the blip is.
spritenumberThe game's blip sprite.
colornumberThe game's blip colour.
scalenumberThe size of the blip.
labelstringThe name of the blip, already translated.
displaynumber, optionalThe game's blip display. Defaults to 4.
shortRangeboolean, optionalDefaults to true.
infotable, 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.

FunctionReturnsWhat it does
DrawText3D(coords, text, scale?, r?, g?, b?)nothingDraws 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)nothingDraws centred text on the screen. scale is a vector2, color is { r, g, b, a } and pos is a vector2.
LoadModel(model)hash or nilLoads a model. nil when it is missing or not loaded within 5 seconds.
LoadAnimDict(dict)booleanLoads an animation dictionary.
LoadAsset(requestNative, hasLoadedNative, asset)booleanLoads any other asset, for example LoadAsset(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, "core").
PlayAnim(dict, name, flag?, duration?)booleanLoads the dictionary and plays the animation on the player. duration is in ms.
SpawnObject(model, coords, heading?, networked?)handle or nilCreates an object. It is local unless networked is true.
SpawnVehicle(model, coords, heading?, networked?)handle or nilCreates a vehicle. It is networked by default.
RemoveEntity(entity)nothingDeletes an object, vehicle or ped that your client owns.
Teleport(coords, heading?)nothingTeleports 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 nilThe map waypoint, or nil when none is set.
GetClosestPlayer(coords, radius)player index, distanceThe 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, distanceThe closest vehicle. The vehicle is 0 when none is near.
GetClosestObject(coords, radius)object, distanceThe closest object. The object is 0 when none is near.
GetClosestPed(coords, radius)ped, distanceThe closest ped.
GetClosestEntity(pool, coords, radius, ignore?)entity, distanceThe same for the pool CObject, CVehicle or CPed.
GetVehiclePlate(vehicle)stringThe plate without padding spaces.
GetVehicleLabel(model)stringThe display name, for example Adder.
GetVehicleMaxSpeed(vehicle)numberThe estimated top speed in km/h.
IsVehicleEmpty(vehicle)booleantrue when nobody sits in it.
GetVehicleFuel(vehicle)numberThe fuel level, 0 to 100.
SetVehicleFuel(vehicle, fuel)booleanSets the fuel level, 0 to 100. false when the vehicle is networked and you don't control it.
UpdateGamerTag(tag, playerIndex)nothingStyles an overhead name tag.
RemoveGamerTags(tags)nothingRemoves overhead name tags.
WaitForPlayer()nothingWaits until the session, the framework and the player are loaded. Call it from a thread.
GetLocaleStrings()tableYour MS.Locales[MS.Locale] over MS.Locales["en"], as one table for your NUI.
GetBoundKey(command, default)stringThe 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, entityA 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.

FunctionReturnsWhat it does
GetLang(key, ...)stringYour 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 nilTrims text from a client and cuts it to limit bytes. nil when nothing is left.
CheckCooldown(store, playerId, seconds)boolean, seconds lefttrue when the player may act again. Otherwise false and the seconds left.
IsNearCoords(playerId, coords, maxDistance)booleanChecks the player's position on the server.
IsNearAny(playerId, points, maxDistance)booleanThe same for a list of points.
IsNearEntity(playerId, entity, maxDistance)booleanThe same for an entity.
GetPlayersInArea(coords, radius, ignore?)number[]The server ids within the radius.
GetClosestPlayer(coords, radius, ignore?)server id, distanceThe closest server id. nil when nobody is near.
SendToPlayers(players, eventName, ...)nothingSends a client event to a list of server ids.
WaitForNetworkEntity(netId)entity or nilWaits up to 5 seconds for a networked entity to exist.
SpawnVehicle(model, coords, heading?, vehicleType?)entity or nilCreates a networked vehicle on the server.
DecodeJson(text, default)anyReads a JSON column. Returns default when the text is not valid.
EncodeVector(coords)stringStores a vector3 as JSON for a column.
DecodeVector(text, default?)vector3 or nilReads a vector3 back from a JSON column.
FormatDateTime(timestamp?)stringYYYY-MM-DD HH:MM:SS, for a DATETIME column.
StartInterval(ms, fn)nothingRuns fn every ms milliseconds. An error is printed and the next run still happens.
SendWebhook(settings, embed)booleanSends 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.

EventArgumentsWhen it fires
more_lib::server:frameworkLoadedframeworkNameThe framework is ready on the server.
more_lib::server:playerLoadedplayerId, playerObjectA player's character has loaded.
more_lib::server:playerDroppedplayerIdA loaded player left.
more_lib::server:setJobplayerId, job, lastJobA player's job changed. lastJob is given on ESX only.
more_lib::client:frameworkLoadedframeworkNameThe framework is ready on the client.
more_lib::client:playerLoadedplayerDataYour character has loaded.
more_lib::client:playerUnloadednoneYour character was unloaded.
more_lib::client:setJobjobYour job changed.
more_lib::client:setGroupgroupYour group changed. ESX only.
more_lib::client:setMoneyaccount, amountAn account balance changed.
more_lib::client:addItemname, countAn item was added. count is the new total.
more_lib::client:removeItemname, countAn item was removed. count is the new total.
more_lib::client:playerDiednoneThe player went down (see MS.Death).
more_lib::client:playerRevivednoneThe player was revived.
more_lib::client:cachechanged fieldsOnly the MORE.Cache fields that changed, for example { vehicle = false } when the player gets out.
more_lib::client:pauseMenuactiveThe 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.

ShapeFieldsNotes
PlayerJobname, label, grade, gradeName, gradeLabel, salary, onDutyonDuty is always true on ESX.
JobListname, label, gradesgrades[grade + 1] is the label of that grade, and an empty text for a grade the job lacks.
PlayerItemname, label, count, metadata?count is 0 when the player has none.
PlayerCharInfofirstName, lastName, gender, birthDate?, phonegender is male or female. phone is empty when the player has no phone.
PlayerWeaponname, label, ammo, components, tintIndexReturned by GetWeapon.
WeaponDataname, label, clip, clipSize, reserveReturned 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 BindingsDefault keyWhat it does
InteractEUses the closest world point in range (command more_interact).
Menu up, Menu down, Menu left, Menu rightArrow keysMove in the open menu. Hold to scroll.
Menu selectEnterSelects the highlighted row.
Menu backBackspaceGoes back one menu.

Last updated