🔧OLD Installation
Here we're going to guide you in the installation of an old origen_inventory version.
Just for versions 1.7 or less.
This guide is going to work only for and old origen_inventory version,
ensure oxmysql
ensure qb-core
ensure origen_inventory
...(make sure to start other scripts that use inventory functions after the origen_inventory)
Add some code
Replace those functions in the qb-core/server/functions.lua
function QBCore.Functions.CreateUseableItem(item, data)
-- print ('^5[QBCore] Creating usable item: ^0', item, GetInvokingResource())
QBCore.UsableItems[item] = data
if GetResourceState('origen_inventory'):match('start') then
exports['origen_inventory']:CreateUsableItem(item, data)
end
end
---Checks if the given item is usable
---@param item string
---@return any
function QBCore.Functions.CanUseItem(item)
return QBCore.UsableItems[item]
end
---Use item
---@param source any
---@param item string
function QBCore.Functions.UseItem(source, item)
if QBCore.UsableItems[item] then
QBCore.UsableItems[item](source, item)
return
end
if GetResourceState('origen_inventory') == 'missing' or not QBCore.UsableItems[item] then return end
exports['origen_inventory']:UseItem(source, item)
end
Replace all the qb-inventory
strings with origen_inventory
in all the resources folder using visual studio code:
ensure oxmysql
ensure es_extended
ensure origen_inventory
...(make sure to start other scripts that use inventory functions after the origen_inventory)
Add some code
Got to es_extended/client/Common.lua a add this line-
if GetResourceState('origen_inventory') ~= 'missing' then
Config.OrigenInventory = true
end
Go to es_extended/client/functions.lua and replace that function
For that function.
function ESX.GetPlayerData()
if Config.QSInventory then
ESX.PlayerData.inventory = exports['qs-inventory']:getUserInventory()
end
if Config.OrigenInventory then
TriggerEvent('__cfx_export_origen_inventory_getPlayerInventory', function(ref)
if ref then
ESX.PlayerData.inventory = ref()
end
end)
end
return ESX.PlayerData
end
Go to es_extended/server/common.lua and add that code
if GetResourceState('origen_inventory') ~= 'missing' then
Config.OrigenInventory = true
Config.PlayerFunctionOverride = 'OrigenInventory'
end
Go to es_extended/server/functions.lua and add that code
AddEventHandler('onResourceStop', function(resourceName)
if (resourceName == "origen_inventory") then
Core.SavePlayers()
end
end)
Go to es_extended/server/functions.lua and replace the old function ESX.RegisterUsableItem for that
function ESX.RegisterUsableItem(item, cb)
Core.UsableItemsCallbacks[item] = cb
if Config.OrigenInventory then
exports['origen_inventory']:CreateUsableItem(item, cb)
end
end
Go to es_extended/server/functions.lua and replace ESX.GetItemLabel for that
function ESX.GetItemLabel(item)
if Config.OrigenInventory then
return exports['origen_inventory']:GetItemLabel(item)
end
if Config.OxInventory then
item = exports.ox_inventory:Items(item)
if item then
return item.label
end
end
if ESX.Items[item] then
return ESX.Items[item].label
else
print(('[^3WARNING^7] Attemting to get invalid Item -> ^5%s^7'):format(item))
end
end
Go to es_extended/server/common.lua
if Config.OrigenInventory then
ESX.Items = exports['origen_inventory']:GetItemList()
end
Got to es_extended/server/functions.lua and replace that function function ESX.UseItem for that
function ESX.UseItem(source, item, ...)
local src, itm = source, item
if type(src) == 'string' then item = src source = itm end
if ESX.Items[item] then
local itemCallback = Core.UsableItemsCallbacks[item]
if Config.OrigenInventory then
return exports['origen_inventory']:UseItem(item, source, ...)
end
if itemCallback then
local success, result = pcall(itemCallback, source, item, ...)
if not success then
return result and print(result) or print(('[^3WARNING^7] An error occured when using item ^5"%s"^7! This was not caused by ESX.'):format(item))
end
end
else
print(('[^3WARNING^7] Item ^5"%s"^7 was used but does not exist!'):format(item))
end
end
Go to es_extended/server/functions.lua and add "and not Config.OrigenInventory" into this line
Add this file to the es_extended/server/classes/overrides
folder
Execute that sql
CREATE TABLE IF NOT EXISTS `gloveboxitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plate` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`plate`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `stashitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`stash` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`stash`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `trunkitems` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plate` varchar(255) DEFAULT NULL,
`items` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`plate`),
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `player_vehicles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`license` varchar(50) DEFAULT NULL,
`citizenid` varchar(50) DEFAULT NULL,
`vehicle` varchar(50) DEFAULT NULL,
`hash` varchar(50) DEFAULT NULL,
`mods` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
`plate` varchar(50) NOT NULL,
`fakeplate` varchar(50) DEFAULT NULL,
`garage` varchar(50) DEFAULT NULL,
`fuel` int(11) DEFAULT 100,
`engine` float DEFAULT 1000,
`body` float DEFAULT 1000,
`state` int(11) DEFAULT 1,
`depotprice` int(11) NOT NULL DEFAULT 0,
`drivingdistance` int(50) DEFAULT NULL,
`status` text DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `plate` (`plate`),
KEY `citizenid` (`citizenid`),
KEY `license` (`license`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
ALTER TABLE `items`
ADD COLUMN `unique` INT(1) NULL DEFAULT 0 COLLATE 'utf8mb3_general_ci';
Last updated