Fivecore
  • Fivecore - FiveM Scripts
  • Discord
  • General
    • Common issues
  • RESOURCES
    • Zombies
      • Installation
      • Usage
      • Functions
        • Server Functions
      • Events
        • Server Events
    • Looting
      • Installation
      • Setup
      • Events
        • Server Events
      • Functions
        • Client Functions
        • Server Functions
      • Loot editor
    • NPC Dialogs
      • Installation
      • Usage
      • Extras
    • Dynamic Guides
      • Installation
      • Usage
    • Interact
      • Installation
      • Usage
      • InteractOptions
      • Functions
        • Client
Powered by GitBook
On this page
  • setPlayerSearchSpeed
  • getRandomItem
  • createCustomSpot
  • removeCustomSpot
  • getCustomSpot
  • updateCustomSpot
  • attachSpotToNetId
  1. RESOURCES
  2. Looting
  3. Functions

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

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.

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)
PreviousClient FunctionsNextLoot editor

Last updated 5 months ago