# v1.2 installation

The functions listed below are taken from the default ESX resources, giving you both the original function to search for and the new function with the required changes made. You're best off looking at the changes yourself and modifying your own code so you don't overwrite any existing modifications required by other resources.

### FILE: es\_extended/client/functions.lua

<details>

<summary>ESX.ShowInventory</summary>

**Original:**

```lua
ESX.ShowInventory = function()
  local playerPed = PlayerPedId()
  local elements, currentWeight = {}, 0

  for k,v in pairs(ESX.PlayerData.accounts) do
    if v.money > 0 then
      local formattedMoney = _U('locale_currency', ESX.Math.GroupDigits(v.money))
      local canDrop = v.name ~= 'bank'

      table.insert(elements, {
        label = ('%s: <span style="color:green;">%s</span>'):format(v.label, formattedMoney),
        count = v.money,
        type = 'item_account',
        value = v.name,
        usable = false,
        rare = false,
        canRemove = canDrop
      })
    end
  end

  for k,v in ipairs(ESX.PlayerData.inventory) do
    if v.count > 0 then
      currentWeight = currentWeight + (v.weight * v.count)

      table.insert(elements, {
        label = ('%s x%s'):format(v.label, v.count),
        count = v.count,
        type = 'item_standard',
        value = v.name,
        usable = v.usable,
        rare = v.rare,
        canRemove = v.canRemove
      })
    end
  end

  for k,v in ipairs(Config.Weapons) do
    local weaponHash = GetHashKey(v.name)

    if HasPedGotWeapon(playerPed, weaponHash, false) then
      local ammo, label = GetAmmoInPedWeapon(playerPed, weaponHash)

      if v.ammo then
        label = ('%s - %s %s'):format(v.label, ammo, v.ammo.label)
      else
        label = v.label
      end

      table.insert(elements, {
        label = label,
        count = 1,
        type = 'item_weapon',
        value = v.name,
        usable = false,
        rare = false,
        ammo = ammo,
        canGiveAmmo = (v.ammo ~= nil),
        canRemove = true
      })
    end
  end

  ESX.UI.Menu.CloseAll()

  ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'inventory', {
    title    = _U('inventory', currentWeight, ESX.PlayerData.maxWeight),
    align    = 'bottom-right',
    elements = elements
  }, function(data, menu)
    menu.close()
    local player, distance = ESX.Game.GetClosestPlayer()
    local elements = {}

    if data.current.usable then
      table.insert(elements, {label = _U('use'), action = 'use', type = data.current.type, value = data.current.value})
    end

    if data.current.canRemove then
      if player ~= -1 and distance <= 3.0 then
        table.insert(elements, {label = _U('give'), action = 'give', type = data.current.type, value = data.current.value})
      end

      table.insert(elements, {label = _U('remove'), action = 'remove', type = data.current.type, value = data.current.value})
    end

    if data.current.type == 'item_weapon' and data.current.canGiveAmmo and data.current.ammo > 0 and player ~= -1 and distance <= 3.0 then
      table.insert(elements, {label = _U('giveammo'), action = 'give_ammo', type = data.current.type, value = data.current.value})
    end

    table.insert(elements, {label = _U('return'), action = 'return'})

    ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'inventory_item', {
      title    = data.current.label,
      align    = 'bottom-right',
      elements = elements,
    }, function(data1, menu1)
      local item, type = data1.current.value, data1.current.type

      if data1.current.action == 'give' then
        local playersNearby = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)

        if #playersNearby > 0 then
          local players, elements = {}, {}

          for k,player in ipairs(playersNearby) do
            players[GetPlayerServerId(player)] = true
          end

          ESX.TriggerServerCallback('esx:getPlayerNames', function(returnedPlayers)
            for playerId,playerName in pairs(returnedPlayers) do
              table.insert(elements, {
                label = playerName,
                playerId = playerId
              })
            end

            ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'give_item_to', {
              title    = _U('give_to'),
              align    = 'bottom-right',
              elements = elements
            }, function(data2, menu2)
              local selectedPlayer, selectedPlayerId = GetPlayerFromServerId(data2.current.playerId), data2.current.playerId
              playersNearby = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0)
              playersNearby = ESX.Table.Set(playersNearby)

              if playersNearby[selectedPlayer] then
                local selectedPlayerPed = GetPlayerPed(selectedPlayer)

                if IsPedOnFoot(selectedPlayerPed) then
                  if type == 'item_weapon' then
                    TriggerServerEvent('esx:giveInventoryItem', selectedPlayerId, type, item, nil)
                    menu2.close()
                    menu1.close()
                  else
                    ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give', {
                      title = _U('amount')
                    }, function(data3, menu3)
                      local quantity = tonumber(data3.value)

                      if quantity then
                        TriggerServerEvent('esx:giveInventoryItem', selectedPlayerId, type, item, quantity)
                        menu3.close()
                        menu2.close()
                        menu1.close()
                      else
                        ESX.ShowNotification(_U('amount_invalid'))
                      end
                    end, function(data3, menu3)
                      menu3.close()
                    end)
                  end
                else
                  ESX.ShowNotification(_U('in_vehicle'))
                end
              else
                ESX.ShowNotification(_U('players_nearby'))
                menu2.close()
              end
            end, function(data2, menu2)
              menu2.close()
            end)
          end, players)
        else
          ESX.ShowNotification(_U('players_nearby'))
        end
      elseif data1.current.action == 'remove' then
        if IsPedOnFoot(playerPed) then
          local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
          ESX.Streaming.RequestAnimDict(dict)

          if type == 'item_weapon' then
            menu1.close()
            TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
            Citizen.Wait(1000)
            TriggerServerEvent('esx:removeInventoryItem', type, item)
          else
            ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_remove', {
              title = _U('amount')
            }, function(data2, menu2)
              local quantity = tonumber(data2.value)

              if quantity then
                menu2.close()
                menu1.close()
                TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
                Citizen.Wait(1000)
                TriggerServerEvent('esx:removeInventoryItem', type, item, quantity)
              else
                ESX.ShowNotification(_U('amount_invalid'))
              end
            end, function(data2, menu2)
              menu2.close()
            end)
          end
        end
      elseif data1.current.action == 'use' then
        TriggerServerEvent('esx:useItem', item)
      elseif data1.current.action == 'return' then
        ESX.UI.Menu.CloseAll()
        ESX.ShowInventory()
      elseif data1.current.action == 'give_ammo' then
        local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
        local closestPed = GetPlayerPed(closestPlayer)
        local pedAmmo = GetAmmoInPedWeapon(playerPed, GetHashKey(item))

        if IsPedOnFoot(closestPed) then
          if closestPlayer ~= -1 and closestDistance < 3.0 then
            if pedAmmo > 0 then
              ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'inventory_item_count_give', {
                title = _U('amountammo')
              }, function(data2, menu2)
                local quantity = tonumber(data2.value)

                if quantity then
                  if pedAmmo >= quantity and quantity > 0 then
                    TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), 'item_ammo', item, quantity)
                    menu2.close()
                    menu1.close()
                  else
                    ESX.ShowNotification(_U('noammo'))
                  end
                else
                  ESX.ShowNotification(_U('amount_invalid'))
                end
              end, function(data2, menu2)
                menu2.close()
              end)
            else
              ESX.ShowNotification(_U('noammo'))
            end
          else
            ESX.ShowNotification(_U('players_nearby'))
          end
        else
          ESX.ShowNotification(_U('in_vehicle'))
        end
      end
    end, function(data1, menu1)
      ESX.UI.Menu.CloseAll()
      ESX.ShowInventory()
    end)
  end, function(data, menu)
    menu.close()
  end)
end
```

**Modified:**

```lua
ESX.ShowInventory = function()
  exports["fz-inventory"]:openInventory()
end
```

</details>

### FILE: es\_extended/server/functions.lua

<details>

<summary>ESX.UseItem</summary>

</details>

<details>

<summary>ESX.SavePlayer</summary>

</details>

### FILE: es\_extended/server/commands.lua

<details>

<summary>clearinventory</summary>

</details>

<details>

<summary>clearloadout</summary>

</details>

<details>

<summary>giveitem</summary>

</details>

### es\_extended/server/main.lua

<details>

<summary>print invalid item</summary>

</details>

### es\_extended/server/classes/player.lua

<details>

<summary>self.getInventory</summary>

</details>

<details>

<summary>self.setInventory</summary>

</details>

<details>

<summary>self.getInventoryItem</summary>

</details>

<details>

<summary>self.addInventoryItem</summary>

</details>

<details>

<summary>self.removeInventoryItem</summary>

</details>

<details>

<summary>self.addWeapon</summary>

</details>

<details>

<summary>self.removeWeapon</summary>

</details>

<details>

<summary>self.setAccountMoney</summary>

</details>

<details>

<summary>self.addAccountMoney</summary>

</details>

<details>

<summary>self.removeAccountMoney</summary>

</details>

<details>

<summary>self.canCarryItem</summary>

</details>

<details>

<summary>self.canSwapItem</summary>

</details>


---

# 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.frozen-scripts.com/scripts/frozen-inventory/installation/v1.2-installation.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.
