ox_inventory edits (optional)
Without Edit
With Edit
Steps
local function CustomDrop(prefix, items, coords, slots, maxWeight, instance, model, rot, offset) local dropId = generateInvId() local inventory = Inventory.Create(dropId, ('%s %s'):format(prefix, dropId:gsub('%D', '')), 'drop', slots or shared.dropslots, 0, maxWeight or shared.dropweight, false, {}) if not inventory then return end inventory.items, inventory.weight = generateItems(inventory, 'drop', items) inventory.coords = coords Inventory.Drops[dropId] = { coords = inventory.coords, instance = instance, model = model, rot = rot, offset = offset, } TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId]) return dropId endlocal function onEnterDrop(point) if not point.instance or point.instance == currentInstance and not point.entity then local model = point.model or client.dropmodel lib.requestModel(model) local entity = CreateObject(model, point.coords.x, point.coords.y, point.coords.z, false, true, true) SetModelAsNoLongerNeeded(model) PlaceObjectOnGroundProperly(entity) FreezeEntityPosition(entity, true) SetEntityCollision(entity, false, true) if point.rot then SetEntityRotation(entity, point.rot.x, point.rot.y, point.rot.z, 5, true) end if point.offset then SetEntityCoords(entity, point.coords.x + point.offset.x, point.coords.y + point.offset.y, point.coords.z + point.offset.z) end point.entity = entity end endlocal function createDrop(dropId, data) local point = lib.points.new({ coords = data.coords, distance = 16, invId = dropId, instance = data.instance, model = data.model, rot = data.rot, offset = data.offset, }) if point.model or client.dropprops then point.distance = 30 point.onEnter = onEnterDrop point.onExit = onExitDrop else point.nearby = nearbyDrop end client.drops[dropId] = point end
Last updated

