NightZoom LogoNightZoom

API Reference

Public exports and events for BJJ Lib v1 integration

This page documents the public API for BJJ Lib v1. Only use these exports and events for integration.

Asset Loading

ExportParametersReturnsDescription
loadModel(model)model: string | numbervoidLoads a model and waits for completion
unloadModel(model)model: string | numbervoidUnloads a model to free memory
loadAnimDict(dict)dict: stringvoidLoads an animation dictionary
unloadAnimDict(dict)dict: stringvoidUnloads an animation dictionary
loadPtfxDict(dict)dict: stringvoidLoads a particle FX dictionary
unloadPtfxDict(dict)dict: stringvoidUnloads a particle FX dictionary

Entity Management

ExportParametersReturnsDescription
networkEntity(entity)entity: numbervoidTakes network control and sets as mission entity

String Utilities

ExportParametersReturnsDescription
capitalizeFirstLetter(str)str: stringstringCapitalizes the first letter of a string
startsWith(str, start)str: string, start: stringbooleanChecks if string starts with prefix

Example Usage

-- Load and spawn a vehicle
exports['bjj_lib']:loadModel('adder')
local vehicle = CreateVehicle('adder', coords, heading, true, false)
exports['bjj_lib']:networkEntity(vehicle)
exports['bjj_lib']:unloadModel('adder')

-- Load animations
exports['bjj_lib']:loadAnimDict('anim@mp_player_intmenu@key_fob@')
TaskPlayAnim(ped, 'anim@mp_player_intmenu@key_fob@', 'fob_click', 8.0, 8.0, -1, 48, 0, false, false, false)

Inventory Integration

ExportParametersReturnsDescription
HasItem(source, item, amount)source: number, item: string, amount?: numberbooleanChecks if player has required item count
ServerhasRequiredItems(source, data)source: number, data: table[]boolean, tableChecks multiple items, returns missing items
damageItem(source, item, amount)source: number, item: table, amount: numberbooleanDamages an item's durability

Parameter Details

HasItem

  • source: Player's server ID
  • item: Item name (string)
  • amount: Required amount (defaults to 1)

ServerhasRequiredItems

  • source: Player's server ID
  • data: Array of { item: string, count: number } tables

damageItem

  • source: Player's server ID
  • item: Item table with slot information
  • amount: Damage amount to apply

Example Usage

-- Check if player has items
if exports['bjj_lib']:HasItem(source, 'lockpick', 1) then
    print('Player has lockpick')
end

-- Check multiple items
local hasItems, missing = exports['bjj_lib']:ServerhasRequiredItems(source, {
    { item = 'steel', count = 5 },
    { item = 'rubber', count = 2 }
})

if not hasItems then
    print('Missing items:', json.encode(missing))
end

Debug Functions

ExportParametersReturnsDescription
debug(msg)msg: stringvoidPrints debug message if debug mode enabled
debugUnpack(data)data: tablevoidPrints all key-value pairs in a table
debug_adv(msg, bool)msg: string, bool: booleanvoidConditional debug printing

Table Utilities

ExportParametersReturnsDescription
GetTableSize(t)t: tablenumberReturns the number of entries in a table
tablelength(t)t: tablenumberAlias for GetTableSize

Example Usage

-- Debug output
exports['bjj_lib']:debug('This is a debug message')
exports['bjj_lib']:debugUnpack({ a = 1, b = 2, c = 3 })

-- Table operations
local myTable = { a = 1, b = 2, c = 3 }
local size = exports['bjj_lib']:GetTableSize(myTable) -- returns 3