# Tgiann Inventory

* Go to **tgiann-inventory/bridge/** and create a new file **av\_business.lua**
* Edit the file and paste the following code inside:

```lua
AddEventHandler('inventory:refresh',function()
	local success, items = pcall(MySQL.query.await, 'SELECT * FROM av_items')
	if success and items and next(items) then
		local dump = {}
		local resource = GetCurrentResourceName()
		local path = GetResourcePath('inventory_images')
		for i = 1, #items do
			local item = items[i]
			if not itemsData[item.name] then
				item.shouldClose = true
				item.unique = false
				item.useable = true
				item.description = item.description
				item.weight = item.weight or 100
				item.type = 'item'
				if item.image then
					PerformHttpRequest(item.image, function (errorCode, resultData, _)
						if errorCode >= 200 and errorCode < 300 then
							local image = assert(io.open(path..'/images/'..item.name..'.png', "wb"))
							image:write(resultData)
							image:flush()
							image:close()
						end
					end)
				end
				item.image = tostring(item.name..'.png')
				dump[i] = item
			end
		end
		if table.type(dump) ~= "empty" then
			local file = {string.strtrim(LoadResourceFile(resource, 'items/items.lua'))}
			file[1] = file[1]:gsub('}$', '')

			local itemFormat = [[
    ['%s'] = {
        name = '%s',
        label = '%s',
        weight = %s,
        type = 'item',
        image = '%s',
        unique = %s,
        useable = %s,
        shouldClose = %s,
        description = %s
    },
]]
			local fileSize = #file
			for _, item in pairs(dump) do
				local formatName = item.name:gsub("'", "\\'"):lower()
				if not itemsData[formatName] then
					fileSize += 1
					file[fileSize] = (itemFormat):format(formatName, item.name, item.label:gsub("'", "\\'"):lower(), item.weight, item.image, item.unique, item.useable, item.shouldClose, item.description and ('"%s"'):format(item.description) or 'nil')
					itemsData[formatName] = item
				end
			end
			file[fileSize+1] = '}'
			SaveResourceFile(resource, 'items/items.lua', table.concat(file), -1)
            itemsData = itemsData
		end
	end
end)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.av-scripts.com/laptop-pack-v3/business/installation/inventories/tgiann-inventory.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
