ox_inventory edits (optional)
This section is completely optional. The script will still work perfectly fine even if you choose not to edit ox_inventory. The point of this edit is to rotate the model that the customDrops spawns so they sit correctly on the ground instead of upright every time.
Without Edit
With Edit


We can achieve this by editing the code responsible for customDrops by passing in a rotation and offset to be used when spawning the model. If you run into any issues and need help please open a ticket in our discord as ox_inventory does not handle support for modified code of their inventory.
Steps
Go to
modules/inventory/server.luaand edit theCustomDropfunction.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 endGo to
client.luawhere you will need to edit both theonEnterDropandcreateDropfunctions.local 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