Exports

Integrate the **NextGen FiveM Crafting** resource with other scripts and systems using these server-side exports. Each export provides functionality to manage blueprints, levels, and crafting benches seamlessly.


Server Exports

getPlayerBlueprints

Retrieves a table containing the player's blueprints.

-- Parameters:
src: number -- The player's server ID
 
-- Example Usage:
local blueprints = exports['nextgenfivem_crafting']:getPlayerBlueprints(src)

givePlayerBlueprint

Grants a blueprint to a player. Returns a boolean indicating success.

-- Parameters:
src: number       -- The player's server ID
blueprint: string -- The blueprint name or ID
 
-- Example Usage:
local success = exports['nextgenfivem_crafting']:givePlayerBlueprint(src, 'pistol')

removePlayerBlueprint

Removes a blueprint from a player. Returns a boolean indicating success.

-- Parameters:
src: number       -- The player's server ID
blueprint: string -- The blueprint name or ID
 
-- Example Usage:
local success = exports['nextgenfivem_crafting']:removePlayerBlueprint(src, 'pistol')

getPlayerLevel

Retrieves the player's current crafting level.

-- Parameters:
src: number -- The player's server ID
 
-- Example Usage:
local level = exports['nextgenfivem_crafting']:getPlayerLevel(src)

setPlayerLevel

Sets the player's global crafting level. Returns a boolean indicating success.

-- Parameters:
src: number   -- The player's server ID
level: number -- The level to assign
 
-- Example Usage:
local success = exports['nextgenfivem_crafting']:setPlayerLevel(src, 10)

setPlayerCategoryLevel

Sets the player's level for a specific crafting category. Returns a boolean indicating success.

-- Parameters:
src: number       -- The player's server ID
category: string  -- The category name or ID
level: number     -- The level to assign
 
-- Example Usage:
local success = exports['nextgenfivem_crafting']:setPlayerCategoryLevel(src, 'weapons', 5)

givePortableItem

Gives a player a portable crafting bench item. Returns a boolean indicating success.

-- Parameters:
src: number       -- The player's server ID
benchType: string -- The bench type name or ID
 
-- Example Usage:
local success = exports['nextgenfivem_crafting']:givePortableItem(src, 'police')

setEntityAsBench

Assigns an entity as a crafting bench. Returns a boolean indicating success.

-- Parameters:
entity: number    -- The entity ID to assign
benchType: string -- The bench type name or ID
 
-- Returns:
result = {
    success: boolean -- Indicates if the entity was successfully assigned as a bench
    message: string -- The result message
}
 
-- Example Usage:
local result = exports['nextgenfivem_crafting']:setEntityAsBench(entity, 'police')

removeEntityAsBench

Removes an entity from being a crafting bench. Returns a boolean indicating success.

-- Parameters:
entity: number -- The entity ID to remove
 
-- Returns:
result = {
    success: boolean -- Indicates if the entity was successfully removed as a bench
    message: string -- The result message
}
 
-- Example Usage:
local result = exports['nextgenfivem_crafting']:removeEntityAsBench(entity)

setCoordAsBench

Assigns a coordinate as a crafting bench. Returns a boolean indicating success.

-- Parameters:
coord: vector4   -- The coordinate to assign
benchType: string -- The bench type name or ID
routingBucket: string -- The routing bucket to assign (optional)
 
-- Returns:
result = {
    success: boolean,
    id: string -- The bench ID
    remove: function -- Function to remove the bench
}
 
-- Example Usage:
local result = exports['nextgenfivem_crafting']:setCoordAsBench(
    vector4(0.0, 0.0, 0.0, 0.0),
    'police',
    1 -- Optional routing bucket
)

getBenchModels

Retrieves a table containing the models for all crafting benches.

-- Returns:
[key: string] = {
    title: string
    model: string
    centerOffset: vector4
    scale: number
}
 
-- Example Usage:
local models = exports['nextgenfivem_crafting']:getBenchModels()