> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dopenuis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Funções

> Seja bem-vindo a aba de funções adicionais do [dope_inventario](https://www.youtube.com/watch?v=hAZ5tLuCmA0&t)

Aqui você encontrará funções que, embora não sejam essenciais para o funcionamento do inventário, podem ser úteis para a sua equipe de desenvolvimento.

## Consultar o nome do item

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="item" type="string" required>
      Index do item presente na lista do inventário entre `[]`
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.itemNameList = function(item)
  	local index = GlobalState.itemList[item]
  	if index and index["nome"] then
  		return index["nome"]
  	end
  	return item
  end
  ```
</ResponseField>

## Consultar o index do item

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="item" type="string" required>
      Index do item presente na lista do inventário entre `[]`
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.itemIndexList = function(item)
  	local index = GlobalState.itemList[item]
  	if index and index["index"] then
  		return index["index"]
  	end
  	return item
  end
  ```
</ResponseField>

## Consultar o tipo do item

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="item" type="string" required>
      Index do item presente na lista do inventário entre `[]`
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.itemTypeList = function(item)
  	local index = GlobalState.itemList[item]
  	if index and index["type"] then
  		return index["type"]
  	end
  	return "usar"
  end
  ```
</ResponseField>

## Consultar o body do item

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="item" type="string" required>
      Index do item presente na lista do inventário entre `[]`
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.itemBodyList = function(item)
  	local index = GlobalState.itemList[item]
  	if index then
  		return index 
  	end
  	return {}
  end
  ```
</ResponseField>

## Consultar o peso do item

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="item" type="string" required>
      Index do item presente na lista do inventário entre `[]`
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.getItemWeight = function(item)
  	local index = GlobalState.itemList[item]
  	if index and index["peso"] then
  		return index["peso"]
  	end
  	return 0
  end
  ```
</ResponseField>

## Consultar a disponibilidade de slots

**Recomendação:** Adicionar ou substituir a função em `vrp/modules/inventory.lua`

<ResponseField>
  <Expandable title="Args">
    <ResponseField name="user_id" type="number" required>
      ID do jogador que está sendo verificado
    </ResponseField>

    <ResponseField name="item" type="string" required>
      Nome de spawn do item
    </ResponseField>
  </Expandable>

  ```lua theme={null}
  vRP.getHaveSlots = function(user_id, item)
      if user_id and item then
          local amount = vRP.getInventoryItemAmount(user_id, item)
          if tonumber(amount) > 0 then
              return true
          else
              local inventoryPlayer = vRP.getInventory(user_id)
              local slots = vRP.getUserIdentity(user_id)["slots"]
              for k,v in pairs(inventoryPlayer) do
                  slots = slots - 1
              end
              if slots > 0 then
                  return true
              else
                  return false
              end
          end
      end
  end
  ```
</ResponseField>
