Dapler Docs
StoreDiscord
  • Welcome
  • SCRIPTS
    • Bridge
      • Installation
      • File Structure
      • Usage
      • Client-side Exports
      • Server-side Exports
    • Notify
      • Installation guide
  • Speech Recognition
    • Installation
    • Requirements
    • Configuration
    • Microphone Access
    • License and Conditions
    • Support
  • Events
Powered by GitBook
On this page
  • Core Exports
  • Extras
  • Shared Utils
  1. SCRIPTS
  2. Bridge

Server-side Exports

dr-bridge also provides various server-side exports that you can call from other server scripts. Below is a detailed breakdown of all the available server-side exports, including input formats, return

Core Exports

  1. GetPlayer(source)

    • Description: Returns the player's data for the specified source.

    • Input:

      • source (number): The player's ID (typically passed as source).

    • Output: Returns a table containing the player's data:

      {
        identifier = string, -- Unique player identifier (e.g., citizenid or steam ID).
        source = number,     -- Player's source ID.
        name = {
          firstname = string,
          lastname = string,
        },
        job = {
          name = string,     -- Job name (e.g., "police").
          label = string,    -- Job label (e.g., "Police Officer").
          payment = number,  -- Job salary.
          onduty = boolean,  -- Whether the player is currently on duty (true/false). Always `true` on ESX by default.
          isboss = boolean,  -- Whether the player is a boss (true/false).
          grade = {
            name = string,   -- Grade name (e.g., "sergeant").
            level = number,  -- Grade level (e.g., 2).
          },
        },
        gang = table | nil, -- Gang info, if used. Same structure as `job`.
        money = {
          cash = number,     -- Player's cash money.
          bank = number,     -- Player's bank balance.
        },
        metadata = table,    -- Additional metadata (e.g., hunger, thirst, custom flags).
        items = table,       -- Player's inventory items.
      }
      
  2. GetJob(source)

    • Description: Returns the player's job information for the specified source.

    • Input:

      • source (number): The player's ID.

    • Output: Returns a table containing:

      {
        name = string,    -- Job name (e.g., "police").
        grade = string,   -- Job grade (e.g., "officer").
      }
  3. SetJob(source, job, grade)

    • Description: Sets the player's job and grade.

    • Input:

      • source (number): The player's ID.

      • job (string): The job name (e.g., "police").

      • grade (string): The job grade (e.g., "officer").

    • Output: None (sets the player's job).

  4. GetMoney(source, account)

    • Description: Retrieves the player's balance for a specific account (e.g., "cash", "bank").

    • Input:

      • source (number): The player's ID.

      • account (string): The account type (e.g., "cash", "bank").

    • Output: Returns a number representing the balance.

  5. AddMoney(source, amount, account)

    • Description: Adds money to the player's specified account.

    • Input:

      • source (number): The player's ID.

      • amount (number): The amount to add.

      • account (string): The account type (e.g., "cash", "bank").

    • Output: None (adds the specified amount).

  6. RemoveMoney(source, amount, account)

    • Description: Removes money from the player's specified account.

    • Input:

      • source (number): The player's ID.

      • amount (number): The amount to remove.

      • account (string): The account type (e.g., "cash", "bank").

    • Output: None (removes the specified amount).

  7. AddItem(source, item, count, slot, metadata)

    • Description: Adds an item to the player's inventory.

    • Input:

      • source (number): The player's ID.

      • item (string): The item name (e.g., "water").

      • count (number): The quantity of the item.

      • slot (number, optional): The inventory slot (default is 1).

      • metadata (table, optional): Any additional item metadata.

    • Output: None (adds the item to the player's inventory).

  8. RemoveItem(source, item, count, slot)

    • Description: Removes an item from the player's inventory.

    • Input:

      • source (number): The player's ID.

      • item (string): The item name (e.g., "water").

      • count (number): The quantity to remove.

      • slot (number, optional): The inventory slot (default is 1).

    • Output: None (removes the item from the player's inventory).

  9. HasItem(source, item, count)

    • Description: Checks if the player has a specific item with a given quantity.

    • Input:

      • source (number): The player's ID.

      • item (string): The item name (e.g., "water").

      • count (number, optional): The quantity to check. Default is 1.

    • Output: Returns boolean (true if the player has the item, false otherwise).

  10. RegisterCallback(name, handler) Description: Registers a server callback that can be triggered from the client. Compatible with both QBCore and ESX through dr-bridge.

    Input:

    • name (string): The name of the callback (must match what the client triggers).

    • handler (function): A function that handles the callback logic. It receives:

      • source (number): The player's server ID who triggered the callback.

      • cb (function): A function you must call with the result to return to the client.

      • ... (any): Any additional arguments passed from the client.

    Output: None (registers the callback).

    Example:

    exports['dr-bridge']:RegisterCallback('my:getMoney', function(source, cb)
        local money = 1000
        cb(money)
    end)
  11. RegisterCommand(name, help, args, cb, permission)

    Description: Registers a server command compatible with both QBCore and ESX. Internally uses QBCore.Commands.Add() or ESX.RegisterCommand() depending on the framework. Automatically handles permission checks using the framework’s built-in system.

    Input:

    • name (string): Command name.

    • help (string, optional): Help text for the command.

    • args (table, optional): Argument definitions (used mainly in QBCore).

    • cb (function): Handler function receiving:

      • source (number): The player's server ID.

      • args (table): Arguments passed from the player.

    • permission (string, optional): Framework-specific group/role name required to use the command (e.g., "admin"). If not set, command is available to all users.

    Output: None (registers the command).

    Example:

    exports['dr-bridge']:RegisterCommand('revive', 'Revive yourself', {}, function(source, args)
        -- Revive logic here
    end, 'admin') -- Only accessible to players with the "admin" g
  12. RegisterUsableItem(itemName, callback)

    Description: Registers a usable item compatible with both QBCore and ESX. Internally uses QBCore.Functions.CreateUseableItem() or ESX.RegisterUsableItem() depending on the framework. Automatically waits for framework initialization if it hasn't completed yet.

    Input:

    • itemName (string): The name of the item to register (e.g., "bandage").

    • callback (function): A function that is called when the player uses the item. Receives:

      • source (number): The server ID of the player who used the item.

    Output: None (registers the item use callback internally in the framework).

    Example:

    exports['dr-bridge']:RegisterUsableItem('bandage', function(source)
        local player = Bridge.GetPlayer(source)
        print(('Player %s used a bandage'):format(player.identifier))
    end)

Extras

  1. GetIdentifiers(source)

    • Description: Returns the player's identifiers (e.g., Steam, license, Discord, IP).

    • Input:

      • source (number): The player's ID.

    • Output: Returns a table containing:

      {
        steam = string,   -- Steam identifier (e.g., "steam:1234567890").
        license = string, -- License identifier (e.g., "license:abcdef123").
        discord = string, -- Discord identifier (e.g., "discord:123456789012345678").
        ip = string,      -- IP address (e.g., "192.168.0.1").
      }
  2. GetPlayerName(source)

    • Description: Returns the player's name for the specified source.

    • Input:

      • source (number): The player's ID.

    • Output: Returns a string representing the player's name.

  3. SendDiscordLog(webhook, title, message, color)

    • Description: Sends a log message to a Discord webhook.

    • Input:

      • webhook (string): The Discord webhook URL.

      • title (string): The title of the log message.

      • message (string): The content of the log message.

      • color (number, optional): The color code for the embed (default is 16777215).

    • Output: None (sends the message to the Discord webhook).

  4. GetOnlineCount()

    • Description: Returns the number of online players.

    • Input: None.

    • Output: Returns a number representing the online player count.

  5. SendChatMessage(source, message, prefix)

    • Description: Sends a chat message to the specified player.

    • Input:

      • source (number): The player's ID.

      • message (string): The message to send.

      • prefix (string, optional): The prefix for the message (default is "[Bridge]").

    • Output: None (sends the message to the chat).

  6. LogToConsole(title, message)

    • Description: Logs a message to the server console.

    • Input:

      • title (string): The title of the log message.

      • message (string): The content of the log message.

    • Output: None (logs the message to the console).


Shared Utils

  1. DebugPrint(message)

    • Description: Prints a debug message to the console if debug mode is enabled.

    • Input:

      • message (string): The message to print.

    • Output: None (prints the message to the console).

  2. TableHasValue(table, value)

    • Description: Checks if a table contains a specific value.

    • Input:

      • table (table): The table to search in.

      • value (any): The value to search for.

    • Output: Returns boolean (true if the value exists, false otherwise).

  3. DeepCopy(table)

    • Description: Creates a deep copy of a table.

    • Input:

      • table (table): The table to copy.

    • Output: Returns a new table that is a deep copy of the input table.

  4. Round(number, decimals)

    • Description: Rounds a number to a specified number of decimal places.

    • Input:

      • number (number): The number to round.

      • decimals (number, optional): The number of decimal places to round to. Default is 0.

    • Output: Returns a number (rounded value).

  5. IsTable(value)

    • Description: Checks if the given value is a table.

    • Input:

      • value (any): The value to check.

    • Output: Returns boolean (true if the value is a table, false otherwise).

  6. WaitForCondition(condition)

    • Description: Waits until a specified condition is met.

    • Input:

      • condition (function): The condition to check (should return true when met).

    • Output: None (waits for the condition).

PreviousClient-side ExportsNextNotify

Last updated 2 months ago