Server Functions

setPlayerSearchSpeed

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

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

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

exports.fivecore_looting:createCustomSpot(id, label, coords, items, excludeEmpty)
  • 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

Return:

  • spotId: string

Example:

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

exports.fivecore_looting:removeCustomSpot(spotId)
  • spotId: string

getCustomSpot

Get all data for a custom spot

exports.fivecore_looting:getCustomSpot(spotId)
  • spotId: string

Return:

  • spot: table

updateCustomSpot

Update data for a custom spot

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

exports.fivecore_looting:attachSpotToNetId(spotId, netId)
  • spotId: string

  • netId: number

Example:

-- 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)

Last updated