Guide to Creating an External Module in Origen Inventory
This guide explains how to create your own module for origen_inventory from another resource.
Itโs written so that anyone can understand it, even if itโs your first time.
What Is a Module?
A module is an extra โtabโ or โsectionโ that you can add to the main inventory.
For example: a stats module, a settings module, crafting, or anything you want.
Each module:
Has its own icon and name.
Displays a custom interface (HTML/JS).
Opens inside the inventory.
Is completely independent โ you control what happens inside the module.
Important Before You Start
Your module must be in a separate resource.
Example:
origen_inventory must be started before, or restarted properly.
If it restarts, your module will be automatically re-registered.
๐งฉ Note:
Origen Inventory support does NOT cover your own logic.
Help is only provided for integration issues (e.g. connection errors or broken exports).
If your module doesnโt do what you want โ thatโs your job ๐
Basic Module Structure
Your resource should include at least:
Base Code (client.lua)
Copy and paste this into your moduleโs client.lua:
UI Structure
Your ui/index.html file can be any web interface.
Example:
Module Parameters
Parameter
Description
id
Unique module identifier (required). Do not repeat IDs.
local function OpenTab()
exports.origen_inventory:sendModuleMessage('test_tab', {
action = 'open',
})
end
local function addModule()
exports.origen_inventory:createModule({
id = 'test_tab', -- Unique module ID (use distinct names)
icon = 'lucide:at-sign', -- Icon displayed in the inventory
ui = ("https://cfx-nui-%s/ui/index.html"):format(GetCurrentResourceName()), -- UI URL
useDefaultBackground = true, -- Use the inventoryโs default background
canShow = function()
return true -- Condition to display the module (you can customize it)
end,
onOpen = function() OpenTab() end, -- What happens when it opens
onClose = function() end -- What happens when it closes
})
end
CreateThread(addModule)
-- Remove the module if your resource stops
AddEventHandler('onResourceStop', function(resourceName)
if resourceName == GetCurrentResourceName() then
exports.origen_inventory:removeModule('test_tab')
end
end)
-- Re-register the module if origen_inventory restarts
AddEventHandler('onResourceStart', function(resourceName)
if resourceName == 'origen_inventory' then
addModule()
end
end)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Module</title>
</head>
<body>
<h1>Hello, this is my module ๐</h1>
</body>
</html>
exports.origen_inventory:sendModuleMessage('MODULE_ID', {
action = 'whatever_you_want',
data = 'you_can_send_data_here'
})