Bridge

WX Bridge Documentation

WX Bridge is an advanced system for FiveM that allows you to bridge multiple frameworks. With WX Bridge, you don't have to write your own support for multiple framework-dependent functions, such as retrieving a player's job. You can use snippets from this system or add the entire system as a dependency, and then use it with exports.

Setup

  1. Download the bridge repository from GitHub
  2. Place the bridge folder in your resources folder
  3. Ensure the resource
example.lua
local PlayerData = exports.wx_bridge:GetPlayerData()
print(json.encode(PlayerData, {
    indent = true
}))

Config file

bridge_config.lua
wx = {}

wx.Debug = true    -- Enables debug prints

wx.DebugIgnore = { -- Ignore debug prints from these resources
    ['wx_unijob'] = true
}

wx.Framework = "auto"       -- [auto / esx / qb / custom]
wx.Dispatch = "cd_dispatch" -- [cd_dispatch / linden / custom]

wx.AdminGroups = {
    ["owner"] = true,
    ["admin"] = true,
    ["moderator"] = true,
    ["helper"] = true,
}

Available Exports

Every export is called through exports.wx_bridge:functionName(args).

Client

FunctionDescriptionParametersReturn Type
GetPlayerData()Returns current player's data, like character info (name, job, etc.).Nonetable
IsPlayerLoaded()Returns true if the player has chosen their character.Noneboolean
SetPlayerData(key, value)Modifies the current player's data.key (string), value (any)None
OpenInventory()Opens the inventory through the framework.NoneNone
ShowNotification(text)Shows a notification through the framework.text (string)None
Dispatch(code, title, message, blip, jobs, important)Client side function for police dispatchcode (string), title (string), message (string), blip (number), jobs (table), important (boolean | number)None
GetJob()Returns player's job nameNonestring
GetJobGrade()Returns player's job grade numberNonenumber
HasItem(item_name)Returns boolean and item count - Checks if player has given item in inventoryitem_name (string)boolean, number
GetInventory()Returns player's inventory contentsNonetable
CloseMenu()Closes any open menuNoneNone

Server

FunctionDescriptionParametersReturn Type
GetPlayer(id)Returns player object (like xPlayer in ESX).id (number)table
GetAllPlayers()Returns all online players.Nonetable
GetPlayerJob(id)Returns player's job.id (number)string
GetPlayerJobGrade(id)Returns player's job grade number.id (number)number
HasPermission(playerId)Returns boolean - check if player has one of the configured admin groups.playerId (number)boolean
AddMoney(playerId, amount)Adds money to player. (with most frameworks to their inventory)playerId (number), amount (number)None
RemoveMoney(playerId, amount)Removes money from player. (with most frameworks from their inventory)playerId (number), amount (number)None
RemoveBankMoney(playerId, amount)Removes money from player's bank.playerId (number), amount (number)None
GetMoney(playerId)Retrieves player's money (with most frameworks from their inventory)playerId (number)number
GetBankMoney(playerId)Retrieves player's money from bank.playerId (number)number
TransferMoney(from, to, amount)Transfers bank money from one player to anotherfrom (number), to (number), amount (number)boolean, string
GetItem(playerId, item_name)Retrieves info about an item from player's inventory.playerId (number), item_name (string)table
CanCarryItem(playerId, item_name, amount)Returns boolean - Checks if player can carry the given item and count.playerId (number), item_name (string), amount (number)boolean
SetJob(playerId, job_name, job_grade)Set player's job.playerId (number), job_name (string), job_grade (number)None
GetIdentifier(playerId)Returns player's rockstar identifier.playerId (number)string
GetPlayerCoords(playerId)Returns the coords of given player ID.playerId (number)vector3