Developer
Overview
ml_bridge exposes a unified API via the Bridge global table. Any ML script that loads @ml_bridge/init.lua can call Bridge.FunctionName() directly. External scripts can use exports.ml_bridge:FunctionName().
Server Exports
System Info
Bridge.IsReady(): Returnstruewhen the bridge is initializedBridge.GetFramework(): Returns detected framework name ('qbox','qbcore','esx','standalone')Bridge.GetInventorySystem(): Returns detected inventory system ('ox','qb','ps','qs','codem','core','origen','tgiann')Bridge.SupportsMetadata(): Returnstrueif the detected inventory supports item metadataBridge.GetPlayers(): Returns table of all online player source IDs
Player Identity
Bridge.HasPermission(src, permission?): Returnstrueif the player has admin permission (checksConfig.AdminPermissions)Bridge.GetPlayer(src): Returns the native framework player objectBridge.GetPlayerId(src): Returns the character ID (citizenid for QB, identifier for ESX)Bridge.GetPlayerName(src): Returns the Steam/FiveM player nameBridge.GetLicense(src): Returns the player's license identifier (license2 preferred)Bridge.GetDiscord(src): Returns Discord mention format (<@id>) or'Not Linked'Bridge.GetSteam(src): Returns Steam identifier or'Unknown'
Job and Duty
Bridge.GetJob(src): Returns job data table ({ name, grade, label })Bridge.SetJob(src, jobName, grade): Sets the player's jobBridge.HasJob(src, jobName): Returnstrueif player has the specified jobBridge.GetDuty(src): Returnstrueif player is on dutyBridge.SetDuty(src, status): Sets duty statusBridge.GetPlayersByJob(jobName): Returns table of source IDs for all players with the specified jobBridge.GetFrameworkJobs(): Returns all registered jobs from the framework
Inventory
Bridge.HasItem(src, item, amount?): Returnstrueif player has at leastamount(default 1) of the itemBridge.GetItemCount(src, item): Returns the count of a specific itemBridge.GetItem(src, item): Returns item data objectBridge.GetItems(src): Returns all items in the player's inventoryBridge.GiveItem(src, item, amount, meta?): Gives an item to the player. Returns success booleanBridge.RemoveItem(src, item, amount): Removes an item from the player. Returns success booleanBridge.GetSlot(src, slot): Returns the item in a specific slotBridge.RemoveSlot(src, slot, count?): Removes items from a specific slotBridge.SetItemMeta(src, slot, metadata): Updates metadata for an item in a slotBridge.CanCarry(src, item, count): Returnstrueif the player can carry the specified amountBridge.ClearInventory(src): Wipes the player's entire inventoryBridge.ConfiscateInventory(src): Confiscates inventory (framework-specific)Bridge.RestoreInventory(src, items?): Restores a previously confiscated inventoryBridge.GetRegisteredItems(): Returns all items registered in the inventory systemBridge.BindUsableItem(item, callback): Registers a usable item handlerBridge.DegradeItem(src, slot, amount): Reduces item durabilityBridge.DrainWeaponDurability(src, weaponHash, amount): Reduces weapon durabilityBridge.GiveItemToFit(src, item, amount, meta?): Gives as many items as the player can carry. Returnssuccess, actualAmount
Money
Bridge.GetMoney(src, account?): Returns balance for the specified account (default'cash')Bridge.AddMoney(src, account, amount): Adds money to the specified accountBridge.RemoveMoney(src, account, amount): Removes money from the specified account
Stash
Bridge.OpenStash(src, id, label, slots, weight, items?, props?): Opens a stash for a playerBridge.OpenPlayerStash(src, targetSrc, slots, weight): Opens another player's inventory as a stashBridge.GetStash(id): Returns the contents of a stashBridge.IsStashEmpty(id): Returnstrueif the stash has no itemsBridge.ClearStash(id): Empties a stashBridge.RegisterInventoryHook(hookType, callback, options?): Registers a hook for inventory events (swapItems, buyItem, etc.)
Player Status
Bridge.GetMeta(src, key): Returns player metadata for a specific keyBridge.SetMeta(src, key, value): Sets player metadataBridge.GetDob(src): Returns the character's date of birthBridge.GetPhone(src): Returns the character's phone numberBridge.GetGang(src): Returns the character's gang dataBridge.GetHunger(src): Returns hunger valueBridge.AddHunger(src, amount): Adds hungerBridge.SetHunger(src, value): Sets hunger to an exact valueBridge.GetThirst(src): Returns thirst valueBridge.AddThirst(src, amount): Adds thirstBridge.SetThirst(src, value): Sets thirst to an exact valueBridge.GetStress(src): Returns stress valueBridge.AddStress(src, amount): Adds stressBridge.RemoveStress(src, amount): Removes stress
Life Cycle
Bridge.Login(src, data): Triggers the player login flowBridge.Logout(src): Triggers the player logout flowBridge.IsPlayerDead(src): Returnstrueif the player is dead (alias:Bridge.IsDead)Bridge.Revive(src): Revives the player
Vehicles
Bridge.GetOwnedVehicles(src): Returns all vehicles owned by the playerBridge.SetVehicleFuel(vehicle, amount): Sets fuel level (requires a server-side entity)
Notification and Logging
Bridge.NotifyPlayer(src, type, message, duration?): Sends a notification to a player via client event. Types:'info','success','error','warning'Bridge.Log(opts): Multi-provider logging (see Logging section below)
Callbacks
Bridge.OnServerRequest(name, callback, secure?): Registers a named server-side callback that can be invoked from clients viaBridge.RequestServer. Whensecure = true, only the registering resource can invoke it
1-- Server: register a callback
2Bridge.OnServerRequest('myScript:getData', function(src, param1)
3 return { result = 'ok', value = param1 }
4end, true) -- secure = true, only this resource can call itClient Exports
System Info
Bridge.IsReady(): Returnstruewhen the bridge is initializedBridge.GetFramework(): Returns detected framework nameBridge.GetInventorySystem(): Returns detected inventory systemBridge.SupportsMetadata(): Returnstrueif the detected inventory supports item metadataBridge.IsPlayerLoaded(): Returnstruewhen the player character is fully loaded
Inventory
Bridge.HasItem(item, amount?): Returnstrueif the local player has the itemBridge.GetItem(item): Returns item data for a specific itemBridge.GetItems(): Returns all items in the local inventoryBridge.GetItemLabel(item): Returns the display label for an itemBridge.GetItemDefinitions(): Returns all registered item definitions from the inventory systemBridge.GetInventoryImagePath(): Returns the path to inventory imagesBridge.GetInventoryImageExt(): Returns the image file extension (default.png)Bridge.OpenInventory(): Opens the inventory UIBridge.CloseInventory(): Closes the inventory UIBridge.OpenStash(stashId, onClose?): Opens a stash. Accepts an optionalonClosecallbackBridge.OnInventoryChange(callback): Registers a callback fired when inventory content changesBridge.SearchItems(item): Searches the inventory for an itemBridge.RegisterItemUse(item, callback): Registers a client-side usable item handlerBridge.DisplayMetadata(data): Displays metadata in the inventory UI
Weapons
Bridge.GetCurrentWeapon(): Returns current weapon data ({ hash, name, slot, durability, melee }) ornilBridge.HasWeaponEquipped(): Returnstrueif a weapon is equipped
Player State
Bridge.GetJob(): Returns current job data ({ name, grade, label })Bridge.GetPlayerStatus(): Returnshunger, thirstvaluesBridge.IsPlayerDead(): Returnstrueif the player is dead
Vehicle
Bridge.GiveVehicleKey(plate): Gives keys for the specified vehicle plateBridge.RemoveVehicleKey(plate): Removes keys for the specified vehicle plateBridge.GetVehicleFuel(vehicle): Returns fuel levelBridge.SetVehicleFuel(vehicle, amount): Sets fuel level
UI
Bridge.Notify(msg, notifType?, duration?): Shows a notification. Types:'info','success','error','warning'. Duration in ms (default 3000)Bridge.ShowTextUI(text, options?): Shows a help text UI elementBridge.HideTextUI(): Hides the help textBridge.Progress(options): Shows a progress bar. Returnstrueif completedBridge.ProgressCircle(options): Shows a circular progress barBridge.CancelProgress(): Cancels an active progress barBridge.InputDialog(title, inputs): Opens an input dialog. Returns submitted valuesBridge.ContextMenu(options): Opens a context menuBridge.ShowMenu(options): Opens a list menuBridge.HideMenu(): Closes the active menu
Dispatch
Bridge.AlertDispatch(data): Sends a dispatch alert. Auto-detects dispatch system (ps-dispatch, cd_dispatch, qs-dispatch, op-dispatch, rcore_dispatch, origen_police). Falls back to built-in blip+notification system
1Bridge.AlertDispatch({
2 message = 'Store Robbery',
3 description = 'Armed robbery in progress',
4 coords = GetEntityCoords(cache.ped),
5 jobs = { 'police', 'sheriff' },
6 code = '10-31',
7 blip = {
8 sprite = 58,
9 scale = 1.0,
10 color = 1,
11 flash = true,
12 text = 'Robbery'
13 },
14})The fallback creates a map blip that lasts 2 minutes and shows a phone notification.
Target Interactions
Target interactions are handled through ml_bridge. Supports ox_target, qb-target, sleepless_interact, and a TextUI fallback.
Bridge.AddEntityTarget(entity, options): Adds target options to a specific entityBridge.RemoveEntityTarget(entity, options?): Removes target from an entityBridge.AddModelTarget(model, options): Adds target to all entities with a specific modelBridge.RemoveModelTarget(model, options?): Removes model targetBridge.AddPlayerTarget(options): Adds target options to playersBridge.RemovePlayerTarget(options?): Removes player targetBridge.AddVehicleTarget(options): Adds target options to vehiclesBridge.RemoveVehicleTarget(options?): Removes vehicle targetBridge.AddPedTarget(options): Adds target options to pedsBridge.RemovePedTarget(options?): Removes ped targetBridge.AddNetEntityTarget(netId, options): Adds target to a network entity by net IDBridge.RemoveNetEntityTarget(netId, options?): Removes target from net entityBridge.AddZoneTarget(options): Adds a box-zone targetBridge.RemoveZoneTarget(name): Removes a zone targetBridge.AddTargetZone(options): Alias forAddZoneTargetBridge.RemoveTargetZone(name): Alias forRemoveZoneTargetBridge.AddTargetSphereZone(options): Adds a sphere-zone targetBridge.RemoveTargetSphereZone(name): Removes a sphere-zone targetBridge.DisableTargeting(disabled): Globally disables/enables the targeting system
Minigames
Bridge.KeySequence(coords, length, hiddenMode, label?, infoText?): Shows a 3D key sequence minigame at worldcoords. Player must presslengthrandom keys (V, C, E, F, G, H, I, X) in order.hiddenModescrambles upcoming keys. Returnstrueon success,falseon ESC/wrong keyBridge.HoldKeySequence(coords, rows, length, timePerKey, label?, infoText?): Shows a multi-row hold-key minigame. Each key must be held fortimePerKeyms.rowsdefines parallel sequences. Returnstrueon completionBridge.ProgressBar3D(coords, duration, scale?, distance?): Shows a 3D progress bar in world space atcoords. Fades in, fills overdurationms, then fades out.scalecontrols size (default1),distanceis max render distance (default10). Returnstruewhen done
Callbacks
Bridge.RequestServer(name, ...): Sends a named request to the server and yields the current coroutine until a response arrives (10s timeout). Must be called inside aCreateThread. Returns the callback result
1-- Client: call a server callback
2CreateThread(function()
3 local data = Bridge.RequestServer('myScript:getData', 'hello')
4 print(data.result) -- 'ok'
5end)Server Logging API
Bridge.Log sends logs to one or more providers (Discord, ox_lib, FiveManage) based on Config.LogProvider.
1Bridge.Log({
2 webhook = 'https://discord.com/api/webhooks/...',
3 title = 'Item Looted',
4 description = 'Player picked up AK-47',
5 color = 'green',
6 player = source,
7 target = targetSource,
8 fields = {
9 { name = 'Item', value = 'AK-47', inline = true },
10 { name = 'Zone', value = 'Military Base', inline = true },
11 },
12})webhook: Discord webhook URL. Set tofalseto skip this logtitle: Embed titledescription: Embed descriptioncolor: Color name ('blue','green','yellow','orange','red','purple','white')player: Source ID. Automatically includes player name, RP name, citizen ID, job, license, Discord, Steamtarget: Target source ID. Same fields as playerfields: Additional embed fieldsprovider: Override the globalConfig.LogProviderfor this specific logdataset: Override FiveManage dataset
When player or target is provided, the log automatically enriches the embed/entry with full player data including RP name, citizen ID, job, and identifiers. No need to build this manually.
Server Events
ml_bridge:server:playerLoaded: Fires when a player finishes loading (any framework: QBCore, QBox, ESX). Automatically re-caches player identifiersml_bridge:server:playerUnloaded: Fires when a player disconnects or unloads
Spatial Utility (Client)
The Spatial global provides a sector-based proximity tracker. It divides the map into 200m sectors and only checks nearby nodes, making it efficient for large numbers of tracked points.
Spatial.Track(id, target, distance, onEnter?, onExit?): Tracks a position (vec3) or entity (number). FiresonEnterwhen player is withindistance,onExitwhen leaving. Returns the nodeSpatial.Remove(id): Stops tracking a nodeSpatial.StartLoop(): Starts the proximity check loop (called automatically on firstTrack)
1Spatial.Track('mySpot', vec3(200, 300, 30), 5.0,
2 function(self) print('Entered zone') end,
3 function(self) print('Left zone') end
4)
5
6-- Later
7Spatial.Remove('mySpot')Spatial is not an export. It is a global available to any client script loaded within ml_bridge's context. ML scripts use it internally for efficient proximity detection without while true loops.