# Lost Items

{% hint style="info" %}
This script allows you to type a command where after you die, once you type the command it will display what items you lost. (incase for voided scenes).
{% endhint %}

<figure><img src="/files/DFHJUGMsoanVW7HQYe8v" alt=""><figcaption></figcaption></figure>

* <mark style="color:orange;">List what items you lost after dying incase you're needing to be refunded by Staff.</mark>

```
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
```

<figure><img src="/files/LhinZZRSRrF3cHV4BUcL" alt=""><figcaption></figcaption></figure>

* This resource is drag/drop. You will just need to add the following inside of your server.cfg after you've dropped the file into your resources.

> <mark style="color:orange;">ensure adminplus-lostitems</mark>

{% hint style="warning" %}
Feel free to customize the command name, on line 24.
{% endhint %}

```
RegisterCommand('lostitems', function(source, args)
  local targetId = tonumber(args[1])
  local xPlayer = ESX.GetPlayerFromId(source)
  
  if targetId then
    -- Admin is trying to view someone else's lost items
    if xPlayer.getGroup() == 'admin' then
      local xTarget = ESX.GetPlayerFromId(targetId)
      if not xTarget then
        print('Player not found.')
        return
      end

      local characterLicense = xTarget.identifier

      if playerInventory[characterLicense] then
        local inventory = playerInventory[characterLicense]

        local itemList = ''
        for _, item in ipairs(inventory) do
          itemList = itemList .. item.name .. ': ' .. item.count .. ', '
        end

        local characterName = xTarget.getName() -- Get the character name
        local message = 'Lost Items for ' .. characterName .. ': ' .. string.sub(itemList, 1, -3) -- Remove the last comma and space

        -- Trigger client event to display the chat message
        TriggerClientEvent('showLostItems', source, message)

      else
        print('No lost items found.')
      end
    else
      print('Insufficient permission to view other player\'s lost items.')
    end
  else
    -- User is trying to view their own lost items
    local characterLicense = xPlayer.identifier

    if playerInventory[characterLicense] then
      local inventory = playerInventory[characterLicense]

      local itemList = ''
      for _, item in ipairs(inventory) do
        itemList = itemList .. item.name .. ': ' .. item.count .. ', '
      end

      local characterName = xPlayer.getName() -- Get the character name
      local message = 'Lost Items for ' .. characterName .. ': ' .. string.sub(itemList, 1, -3) -- Remove the last comma and space

      -- Trigger client event to display the chat message
      TriggerClientEvent('showLostItems', source, message)
    else
      print('No lost items found.')
    end
  end
end, true)
```

<pre><code><strong>⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
</strong></code></pre>

<figure><img src="/files/cSa9GTZM3fGHbSakyouX" alt=""><figcaption></figcaption></figure>

```markup
V 1.0.0
```

* Original Release

```
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
```

<figure><img src="/files/dkaSynFFlTAmJ7ocaag6" alt=""><figcaption></figcaption></figure>

{% @github-files/github-code-block url="<https://github.com/itsAdminPlus/adminplus-anticollision>" %}


---

# 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.adminplus.dev/free-scripts/lost-items.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.
