Get Items
A function which gets the items that exist in the server. How you can adapt the function for other framework example.
Each item is in the form of ...
items[1] = {
type = "item",
item = "water",
label = "Water",
limit = 10, -- Optional
}
VORP
SConfig.GetItems = function()
local items = {
-- Put all weapons here
}
local result = MySQL.Sync.fetchAll("SELECT * FROM items", {})
for _, db_item in pairs(result) do
if db_item.id then
items[#items+1] = {
type = "item",
item = db_item.item,
label = db_item.label,
limit = db_item.limit,
}
end
end
return items
end
QBCore
SConfig.GetItems = function()
local items = {}
for itemName, itemData in pairs(QBCore.Shared.Items) do
items[#items + 1] = {
type = "item",
item = itemName,
label = itemData.label,
}
end
return items
end
Last updated
Was this helpful?