2025-07-27 05:45:43 +02:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- List of prop models that should be targetable as immediate shredders
|
2025-07-27 21:33:14 +02:00
|
|
|
local shredderPropModels = {
|
|
|
|
'p_secret_weapon_02',
|
2025-07-28 01:05:18 +02:00
|
|
|
'prop_bin_08a'
|
|
|
|
}
|
|
|
|
|
2025-07-28 01:44:42 +02:00
|
|
|
-- List of prop models that should be targetable as storage containers (formerly trash bins)
|
2025-07-28 01:05:18 +02:00
|
|
|
local trashBinPropModels = {
|
2025-07-27 21:33:14 +02:00
|
|
|
'prop_bin_01a',
|
|
|
|
'prop_bin_03a',
|
|
|
|
'prop_bin_04a',
|
|
|
|
'prop_bin_07a',
|
|
|
|
'prop_dumpster_01a',
|
|
|
|
'prop_dumpster_02a',
|
|
|
|
'prop_dumpster_02b',
|
|
|
|
'prop_dumpster_3a'
|
2025-07-27 05:45:43 +02:00
|
|
|
}
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Variable to store the current entity being interacted with
|
2025-07-28 01:05:18 +02:00
|
|
|
local currentEntity = nil
|
|
|
|
local currentType = nil
|
2025-07-27 21:54:10 +02:00
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Add QB-Target to all matching props in the world
|
2025-07-27 05:45:43 +02:00
|
|
|
Citizen.CreateThread(function()
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Add target to shredder props
|
2025-07-28 01:36:31 +02:00
|
|
|
exports['qb-target']:AddTargetModel(shredderPropModels, {
|
2025-07-28 01:38:05 +02:00
|
|
|
options = {
|
|
|
|
{
|
|
|
|
type = "client",
|
|
|
|
event = "disposal:openInventory",
|
|
|
|
icon = "fas fa-dumpster",
|
|
|
|
label = "Müllschredder öffnen",
|
|
|
|
action = function(entity)
|
|
|
|
currentEntity = entity
|
|
|
|
currentType = "shredder"
|
|
|
|
TriggerEvent('disposal:openInventory')
|
|
|
|
end,
|
|
|
|
canInteract = function()
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type = "client",
|
|
|
|
event = "disposal:openMenu",
|
|
|
|
icon = "fas fa-fire",
|
|
|
|
label = "Items vernichten",
|
|
|
|
action = function(entity)
|
|
|
|
currentEntity = entity
|
|
|
|
currentType = "shredder"
|
|
|
|
TriggerEvent('disposal:openMenu')
|
|
|
|
end,
|
|
|
|
canInteract = function()
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
},
|
2025-07-28 01:36:31 +02:00
|
|
|
distance = 2.0
|
|
|
|
})
|
|
|
|
|
2025-07-28 01:44:42 +02:00
|
|
|
-- Add target to storage container props (formerly trash bins)
|
2025-07-28 01:36:31 +02:00
|
|
|
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
2025-07-28 01:38:05 +02:00
|
|
|
options = {
|
|
|
|
{
|
|
|
|
type = "client",
|
|
|
|
event = "disposal:openInventory",
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = "fas fa-box-open",
|
|
|
|
label = "Lager öffnen",
|
2025-07-28 01:38:05 +02:00
|
|
|
action = function(entity)
|
|
|
|
currentEntity = entity
|
|
|
|
currentType = "trash"
|
|
|
|
TriggerEvent('disposal:openInventory')
|
|
|
|
end,
|
|
|
|
canInteract = function()
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type = "client",
|
|
|
|
event = "disposal:openMenu",
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = "fas fa-archive",
|
|
|
|
label = "Items lagern",
|
2025-07-28 01:38:05 +02:00
|
|
|
action = function(entity)
|
|
|
|
currentEntity = entity
|
|
|
|
currentType = "trash"
|
|
|
|
TriggerEvent('disposal:openMenu')
|
|
|
|
end,
|
|
|
|
canInteract = function()
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
},
|
2025-07-28 01:36:31 +02:00
|
|
|
distance = 2.0
|
|
|
|
})
|
|
|
|
|
2025-07-28 01:44:42 +02:00
|
|
|
print("^2[DISPOSAL]^7 Added QB-Target to " .. #shredderPropModels .. " shredder models and " .. #trashBinPropModels .. " storage container models")
|
2025-07-28 01:36:31 +02:00
|
|
|
end)
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Function to get container ID from entity
|
2025-07-28 01:36:31 +02:00
|
|
|
function GetContainerIDFromEntity(entity, type)
|
|
|
|
if not entity or not DoesEntityExist(entity) then return nil end
|
|
|
|
|
|
|
|
local model = GetEntityModel(entity)
|
|
|
|
local entityCoords = GetEntityCoords(entity)
|
|
|
|
return type .. "_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
|
|
|
|
end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Open container inventory
|
2025-07-28 01:36:31 +02:00
|
|
|
RegisterNetEvent('disposal:openInventory', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
if not currentEntity or not DoesEntityExist(currentEntity) then
|
|
|
|
lib.notify({
|
2025-07-28 01:44:42 +02:00
|
|
|
title = currentType == "shredder" and 'Müllschredder' or 'Lager',
|
|
|
|
description = currentType == "shredder" and 'Kein Schredder gefunden!' or 'Kein Lager gefunden!',
|
2025-07-28 01:36:31 +02:00
|
|
|
type = 'error'
|
2025-07-27 22:17:12 +02:00
|
|
|
})
|
2025-07-28 01:36:31 +02:00
|
|
|
return
|
2025-07-27 22:17:12 +02:00
|
|
|
end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Get container ID
|
2025-07-28 01:36:31 +02:00
|
|
|
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
|
|
|
if not containerID then return end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Open inventory with this unique ID
|
2025-07-28 01:36:31 +02:00
|
|
|
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
|
|
|
end)
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Open disposal menu
|
2025-07-28 01:36:31 +02:00
|
|
|
RegisterNetEvent('disposal:openMenu', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
if not currentEntity or not DoesEntityExist(currentEntity) then
|
2025-07-28 01:36:31 +02:00
|
|
|
lib.notify({
|
2025-07-28 01:44:42 +02:00
|
|
|
title = currentType == "shredder" and 'Müllschredder' or 'Lager',
|
|
|
|
description = currentType == "shredder" and 'Kein Schredder gefunden!' or 'Kein Lager gefunden!',
|
2025-07-28 01:36:31 +02:00
|
|
|
type = 'error'
|
2025-07-28 01:30:54 +02:00
|
|
|
})
|
2025-07-28 01:36:31 +02:00
|
|
|
return
|
2025-07-28 01:20:56 +02:00
|
|
|
end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Get container ID
|
2025-07-28 01:36:31 +02:00
|
|
|
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
|
|
|
if not containerID then return end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Get items in this container
|
2025-07-28 01:36:31 +02:00
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
|
|
|
end)
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Show menu with items
|
2025-07-28 01:44:42 +02:00
|
|
|
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type)
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Make sure items is a table
|
2025-07-28 01:36:31 +02:00
|
|
|
items = items or {}
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Check if items is empty
|
2025-07-28 01:36:31 +02:00
|
|
|
if next(items) == nil then
|
|
|
|
lib.notify({
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
|
|
|
description = type == "shredder" and 'Der Schredder ist leer!' or 'Das Lager ist leer!',
|
2025-07-28 01:36:31 +02:00
|
|
|
type = 'error'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local menuOptions = {}
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- All items action option
|
2025-07-28 01:44:42 +02:00
|
|
|
local actionText = type == "shredder" and "ALLE ITEMS VERNICHTEN" or "ALLE ITEMS LAGERN"
|
2025-07-28 01:38:05 +02:00
|
|
|
local actionDesc = type == "shredder"
|
|
|
|
and 'Vernichtet alle Items im Schredder permanent!'
|
2025-07-28 01:44:42 +02:00
|
|
|
or 'Lagert alle Items im Container!'
|
2025-07-28 01:38:05 +02:00
|
|
|
|
2025-07-28 01:36:31 +02:00
|
|
|
table.insert(menuOptions, {
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and '🔥 ' .. actionText or '📦 ' .. actionText,
|
2025-07-28 01:38:05 +02:00
|
|
|
description = actionDesc,
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = type == "shredder" and 'fire' or 'archive',
|
2025-07-28 01:36:31 +02:00
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
confirmDestroyAll(containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
table.insert(menuOptions, {
|
|
|
|
title = '─────────────────',
|
|
|
|
description = 'Einzelne Items:',
|
|
|
|
disabled = true
|
|
|
|
})
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Add individual items to menu
|
2025-07-28 01:36:31 +02:00
|
|
|
local hasItems = false
|
|
|
|
for slot, item in pairs(items) do
|
|
|
|
if item and item.amount and item.amount > 0 then
|
|
|
|
hasItems = true
|
|
|
|
table.insert(menuOptions, {
|
|
|
|
title = (item.label or item.name),
|
|
|
|
description = 'Anzahl: ' .. item.amount .. ' | Slot: ' .. slot,
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = type == "shredder" and 'trash' or 'box',
|
2025-07-28 01:36:31 +02:00
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
confirmDestroySingle(item.name, item.amount, slot, containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if not hasItems then
|
|
|
|
lib.notify({
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
|
|
|
description = type == "shredder" and 'Der Schredder ist leer!' or 'Das Lager ist leer!',
|
2025-07-28 01:36:31 +02:00
|
|
|
type = 'error'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
lib.registerContext({
|
|
|
|
id = 'disposal_menu',
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and '🗑️ Müllschredder Verwaltung' or '📦 Lager Verwaltung',
|
2025-07-28 01:36:31 +02:00
|
|
|
options = menuOptions
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('disposal_menu')
|
|
|
|
end)
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Confirm single item disposal
|
|
|
|
function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
2025-07-28 01:44:42 +02:00
|
|
|
local actionText = type == "shredder" and "vernichten" or "lagern"
|
2025-07-28 01:38:05 +02:00
|
|
|
local actionDesc = type == "shredder"
|
|
|
|
and (itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!')
|
2025-07-28 01:44:42 +02:00
|
|
|
or (itemName .. ' (' .. amount .. 'x) wird im Lager gespeichert!')
|
2025-07-28 01:38:05 +02:00
|
|
|
|
2025-07-28 01:36:31 +02:00
|
|
|
lib.registerContext({
|
|
|
|
id = 'dispose_single_confirm',
|
2025-07-28 01:38:05 +02:00
|
|
|
title = '⚠️ Item ' .. actionText .. '?',
|
2025-07-28 01:36:31 +02:00
|
|
|
options = {
|
|
|
|
{
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and '🔥 Ja, vernichten' or '📦 Ja, lagern',
|
2025-07-28 01:38:05 +02:00
|
|
|
description = actionDesc,
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = type == "shredder" and 'check' or 'box',
|
2025-07-28 01:36:31 +02:00
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = '❌ Abbrechen',
|
|
|
|
description = 'Zurück zum Hauptmenü',
|
|
|
|
icon = 'times',
|
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('dispose_single_confirm')
|
|
|
|
end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Confirm all items disposal
|
|
|
|
function confirmDestroyAll(containerID, type)
|
2025-07-28 01:44:42 +02:00
|
|
|
local actionText = type == "shredder" and "VERNICHTEN" or "LAGERN"
|
2025-07-28 01:38:05 +02:00
|
|
|
local actionDesc = type == "shredder"
|
|
|
|
and 'ALLE Items im Schredder werden permanent gelöscht!'
|
2025-07-28 01:44:42 +02:00
|
|
|
or 'ALLE Items werden im Lager gespeichert!'
|
2025-07-28 01:38:05 +02:00
|
|
|
|
2025-07-28 01:36:31 +02:00
|
|
|
lib.registerContext({
|
|
|
|
id = 'dispose_all_confirm',
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and '⚠️ WARNUNG ⚠️' or '📦 LAGERUNG',
|
2025-07-28 01:36:31 +02:00
|
|
|
options = {
|
|
|
|
{
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and '🔥 JA, ALLES VERNICHTEN' or '📦 JA, ALLES LAGERN',
|
2025-07-28 01:38:05 +02:00
|
|
|
description = actionDesc,
|
2025-07-28 01:44:42 +02:00
|
|
|
icon = type == "shredder" and 'fire' or 'archive',
|
2025-07-28 01:36:31 +02:00
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
TriggerServerEvent('disposal:server:disposeAll', containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = '❌ Abbrechen',
|
|
|
|
description = 'Zurück zum Hauptmenü',
|
|
|
|
icon = 'times',
|
|
|
|
onSelect = function()
|
2025-07-28 01:38:05 +02:00
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
2025-07-28 01:36:31 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('dispose_all_confirm')
|
|
|
|
end
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Success notification with effect
|
2025-07-28 01:36:31 +02:00
|
|
|
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|
|
|
lib.notify({
|
2025-07-28 01:44:42 +02:00
|
|
|
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
2025-07-28 01:36:31 +02:00
|
|
|
description = message,
|
|
|
|
type = 'success',
|
|
|
|
duration = 4000
|
|
|
|
})
|
|
|
|
|
2025-07-28 01:38:05 +02:00
|
|
|
-- Particle effect
|
2025-07-28 01:36:31 +02:00
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
RequestNamedPtfxAsset("core")
|
|
|
|
while not HasNamedPtfxAssetLoaded("core") do
|
|
|
|
Wait(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
UseParticleFxAssetNextCall("core")
|
|
|
|
|
2025-07-28 01:44:42 +02:00
|
|
|
-- Different effects for shredder vs storage
|
2025-07-28 01:36:31 +02:00
|
|
|
if type == "shredder" then
|
2025-07-28 01:38:05 +02:00
|
|
|
-- More intense effect for shredder
|
2025-07-28 01:36:31 +02:00
|
|
|
StartParticleFxNonLoopedAtCoord("ent_sht_flame", coords.x, coords.y, coords.z + 1.0, 0.0, 0.0, 0.0, 1.0, false, false, false)
|
|
|
|
PlaySoundFrontend(-1, "CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", 1)
|
|
|
|
else
|
2025-07-28 01:44:42 +02:00
|
|
|
-- Subtle effect for storage
|
2025-07-28 01:36:31 +02:00
|
|
|
StartParticleFxNonLoopedAtCoord("ent_sht_dust", coords.x, coords.y, coords.z + 0.5, 0.0, 0.0, 0.0, 1.0, false, false, false)
|
|
|
|
PlaySoundFrontend(-1, "PICK_UP", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
|
|
|
|
end
|
|
|
|
end)
|