Drop Props
Installation

Installation

Download the Script

First things first, head over to keymaster (opens in a new tab) and download the latest version of the script.

Place in Resources

Once downloaded, extract the caue_drop_props folder and place it directly into your server's resources directory.

Add to Server Configuration

Now, open your server.cfg file and add the following line:

ensure caue_drop_props
āš ļø

Always ensure you load any required dependencies before caue_drop_props in your server.cfg to avoid issues!

Enable Drop Props in ox_inventory

For the script to function correctly, you need to activate the drop props feature within ox_inventory. Ensure this setting is set to true in your server configuration:

setr inventory:dropprops true

Integrate with ox_inventory Client Functions

You'll need to add specific script exports to your @ox_inventory/client.lua file. Follow the instructions below for each function:

onEnterDrop

Locate the function and add the highlighted line:

local function onEnterDrop(point)
	if not point.instance or point.instance == currentInstance and not point.entity then
		local model = point.model or client.dropmodel
 
        if not IsModelValid(model) and not IsModelInCdimage(model) then
            model = client.dropmodel
        end
		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)
 
		point.entity = entity
 
		exports.caue_drop_props:LoadDrop(point.invId, point.coords, entity) -- ADD THIS LINE
	end
end

onExitDrop

Locate the function and add the highlighted line:

local function onExitDrop(point)
	local entity = point.entity
 
	if entity then
		Utils.DeleteEntity(entity)
		point.entity = nil
		exports.caue_drop_props:UnloadDrop(point.invId)  -- ADD THIS LINE
	end
end

ox_inventory:removeDrop

Locate the event handler and add the highlighted line:

RegisterNetEvent('ox_inventory:removeDrop', function(dropId)
	if client.drops then
		local point = client.drops[dropId]
 
		if point then
			client.drops[dropId] = nil
			point:remove()
 
			if point.entity then
				Utils.DeleteEntity(point.entity)
				exports.caue_drop_props:UnloadDrop(point.invId) -- ADD THIS LINE
			end
		end
	end
end)

instance

Locate the state bag change handler and add the highlighted line:

AddStateBagChangeHandler('instance', stateId, function(_, _, value)
	currentInstance = value
 
	if client.drops then
		for dropId, point in pairs(client.drops) do
			if point.instance then
				if point.instance ~= value then
					if point.entity then
						Utils.DeleteEntity(point.entity)
						point.entity = nil
						exports.caue_drop_props:UnloadDrop(point.invId) -- ADD THIS LINE
					end
 
					point:remove()
				else
					createDrop(dropId, point)
				end
			end
		end
	end
end)

Configure the Script

Now that the script is installed, you can tailor its behavior to your server's specific needs. Proceed to the Configuration section for detailed information on how to customize every aspect of the script.