> For the complete documentation index, see [llms.txt](https://fivecore.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fivecore.gitbook.io/home/resources/looting/functions/server-functions.md).

# Server Functions

## setPlayerSearchSpeed

Update the search speed for each player item, which by default is 2 seconds (2000)

```lua
exports.fivecore_looting:setPlayerSearchSpeed(playerId, newSpeed)
```

* playerId: `number`
* newSpeed: `number`
  * New search speed in ms, 1000 = 1 second

## getRandomItem

Get a random item inside specified category

```lua
exports.fivecore_looting:getRandomItem(category)
```

* category: `string`

Return:

* randomItem: `table`
  * item: `string`
  * metadata: `any`
  * amount: `number`
  * label: `string`

## createCustomSpot

Creates a new independent loot point, useful if you already have a list of coordinates

{% hint style="warning" %}
In this way of creating, you need to specify several details: the items available at the point, their coordinates, the interface text, item respawn behavior, and how the player will access the loot. If you want to create a new object, or more points from existing objects, use the built-in loot editor.
{% endhint %}

<pre class="language-lua"><code class="lang-lua"><strong>exports.fivecore_looting:createCustomSpot(id, label, coords, items, excludeEmpty)
</strong></code></pre>

* id?: string
* label: string
* coords: vector3
* items: table
  * item: `string`
  * amount: `number`
  * metadata?: `any`
* excludeEmpty?: `boolean`
  * Spot should be automatically deleted when there are no more items

&#x20; Return:

* spotId: `string`

Example:

```lua
local myNewSpot = exports.fivecore_looting:createCustomSpot(nil, 'My custom box', vector3(10.0, 10.0, 10.0), {
    {item = 'repairkit', amount = 1},
    {item = 'ammo-22', amount = 15},
    {item = 'WEAPON_ASSAULTRIFLE_MK2', metadata = {durability = 50}, amount = 1},
}, false)
```

## removeCustomSpot

Remove a created custom spot

```lua
exports.fivecore_looting:removeCustomSpot(spotId)
```

* spotId: `string`

## getCustomSpot

Get all data for a custom spot

```lua
exports.fivecore_looting:getCustomSpot(spotId)
```

* spotId: `string`

Return:

* spot: `table`

## updateCustomSpot

Update data for a custom spot

```lua
exports.fivecore_looting:updateCustomSpot(spotId, label, coords, items)
```

* spotId: `string`
* label: `string`
* coords: `vector3`
* items: `table`
  * item: `string`
  * amount: `number`
  * metadata?: `any`

## attachSpotToNetId

Attach a created custom spot to a especific netId as a ped, object or a vehicle. Can be useful for adding loot after an entity dies, for example

```lua
exports.fivecore_looting:attachSpotToNetId(spotId, netId)
```

* spotId: string
* netId: number

Example:

```lua
-- Adding loot to a zombie that has killed
AddEventHandler('fivecore_zombies:zombieKilled', function (playerId, coords, zombieData)
    local items = {}
    for i = 1, math.random(1, 3) do
        items[#items+1] = self:getRandomItem('medical')
    end
    local lootSpot = self:createCustomSpot('zombie_'..zombieData.netId, zombieData.label, coords, items, true)
    self:attachSpotToNetId(lootSpot, zombieData.netId)
end)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://fivecore.gitbook.io/home/resources/looting/functions/server-functions.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.
