A small script for qb-core that adds the ability to place props.
If you want to support me use ko-fi❤️.
- Metadata saving of the item
- Saves the citizenid of the Player that placed the item
- Ability to pickup the item with qb-target
- Support more inventories
Dependencies
- core_inventory or qb-inventory
- qb-target
- qb-core
Rename the resource from "qb-propplacing-main" to "qb-propplacing" and put it into your resources folder.
Import the import.sql file into your db.
Search in core_inventory/client/main.lua:
RegisterNUICallback("useItem", function(data)
TriggerServerEvent('core_inventory:server:useItem', data['item'], data['exact'])
end)
and add below:
RegisterNUICallback("placeItem", function(data)
TriggerEvent('qb-propplacing:client:placeProp', data['item'], data['prop'])
end)
Search in core_inventory/config.lua:
['use'] = 'USE',
and add below:
['place'] = 'PLACE',
Search in core_inventory/html/script.js:
function dropItem(id, inventory) {
$.post('https://core_inventory/dropItem', JSON.stringify({
item: id,
inventory: inventory || null
}));
}
and add below:
function placeItem(name, prop) {
closeMenu();
$.post('https://core_inventory/placeItem', JSON.stringify({
item: name,
prop: prop
}));
}
Search in core_inventory/html/script.js:
if (
$(el).parent().attr('inventory') == 'content-' + cid &&
$(el).parent().attr('category') == 'weapons'
) {
base =
base +
'<div class="dropdown-option shadow-pop-br" onclick="openAttachemnts(\'' +
$(el).parent().attr('id') +
'\')">' +
getText('attachments') +
'</div>'
}
and add below:
if (qbitems[$(el).parent().attr('name')].prop) {
base =
base +
'<div class="dropdown-option shadow-pop-br" onclick="placeItem(\'' +
$(el).parent().attr('name') +
"', '" +
qbitems[$(el).parent().attr('name')].prop +
'\')">' +
getText('place') +
'</div>'
}
Search in qb-inventory/html/ui.html:
<div class="inv-option-item" id="item-use"><p>USE</p></div>
and add below:
<div class="inv-option-item" id="item-place"><p>PLACE</p></div>
Search in qb-inventory/html/js/app.js:
$('#item-use').droppable({
hoverClass: 'button-hover',
drop: function (event, ui) {
setTimeout(function () {
IsDragging = false
}, 300)
fromData = ui.draggable.data('item')
fromInventory = ui.draggable.parent().attr('data-inventory')
if (fromData.useable) {
if (fromData.shouldClose) {
Inventory.Close()
}
$.post(
'https://qb-inventory/UseItem',
JSON.stringify({
inventory: fromInventory,
item: fromData
})
)
}
}
})
and add below:
$('#item-place').droppable({
hoverClass: 'button-hover',
drop: function (event, ui) {
setTimeout(function () {
IsDragging = false
}, 300)
fromData = ui.draggable.data('item')
if (fromData.useable) {
Inventory.Close()
$.post(
'https://qb-inventory/PlaceItem',
JSON.stringify({
item: fromData
})
)
}
}
})
Search in qb-inventory/client/main.lua:
RegisterNUICallback('UseItem', function(data, cb)
TriggerServerEvent('inventory:server:UseItem', data.inventory, data.item)
cb('ok')
end)
and add below:
RegisterNUICallback('PlaceItem', function(data, cb)
local prop = QBCore.Shared.Items[data.item.name].prop
TriggerEvent('qb-propplacing:client:placeProp', data.item, prop)
cb('ok')
end)
Just add prop = 'NAME OF THE PROP',
for the desired item in your qb-core items.lua
Make sure the prop works with qb-target because some of them don't have collision
List of props https://forge.plebmasters.de/objects/