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:
numbernewSpeed:
numberNew search speed in ms, 1000 = 1 second
getRandomItem
Get a random item inside specified category
exports.fivecore_looting:getRandomItem(category)category:
string
Return:
randomItem:
tableitem:
stringmetadata:
anyamount:
numberlabel:
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:
stringamount:
numbermetadata?:
any
excludeEmpty?:
booleanSpot 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:
stringlabel:
stringcoords:
vector3items:
tableitem:
stringamount:
numbermetadata?:
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