local QBCore = exports['qb-core']:GetCoreObject() -- List of prop models that should be targetable as shredders local shredderPropModels = { 'p_secret_weapon_02', 'prop_bin_08a', 'prop_bin_01a', 'prop_bin_03a', 'prop_bin_04a', 'prop_bin_07a', 'prop_dumpster_01a', 'prop_dumpster_02a', 'prop_dumpster_02b', 'prop_dumpster_3a' } -- Add QB-Target to all matching props in the world Citizen.CreateThread(function() -- Add target to all existing props for _, model in ipairs(shredderPropModels) do local modelHash = GetHashKey(model) -- Add QB-Target to this model exports['qb-target']:AddTargetModel(model, { options = { { type = "client", event = "shredder:openInventory", icon = "fas fa-dumpster", label = "Müllschredder öffnen", canInteract = function() return true end, }, { type = "client", event = "shredder:openMenu", icon = "fas fa-fire", label = "Items vernichten", canInteract = function() return true end, } }, distance = 2.0 }) end print("^2[SHREDDER]^7 Added QB-Target to " .. #shredderPropModels .. " shredder prop models") end) -- Schredder Inventar öffnen RegisterNetEvent('shredder:openInventory', function() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) -- Get the entity player is targeting local entity = exports['qb-target']:GetCurrentEntity() if not entity or not DoesEntityExist(entity) then lib.notify({ title = 'Müllschredder', description = 'Kein Schredder gefunden!', type = 'error' }) return end -- Get entity model and position for unique ID local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) -- Open inventory with this unique ID TriggerServerEvent('shredder:server:openInventory', shredderID) end) -- Vernichtungsmenü öffnen RegisterNetEvent('shredder:openMenu', function() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) -- Get the entity player is targeting local entity = exports['qb-target']:GetCurrentEntity() if not entity or not DoesEntityExist(entity) then lib.notify({ title = 'Müllschredder', description = 'Kein Schredder gefunden!', type = 'error' }) return end -- Get entity model and position for unique ID local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) -- Get items in this shredder TriggerServerEvent('shredder:server:getItems', shredderID) end) -- Menü mit Items anzeigen RegisterNetEvent('shredder:client:showMenu', function(items) if not items or #items == 0 then lib.notify({ title = 'Müllschredder', description = 'Der Schredder ist leer!', type = 'error' }) return end local menuOptions = {} -- Alle Items vernichten Option table.insert(menuOptions, { title = '🔥 ALLE ITEMS VERNICHTEN', description = 'Vernichtet alle Items im Schredder permanent!', icon = 'fire', onSelect = function() confirmDestroyAll() end }) table.insert(menuOptions, { title = '─────────────────', description = 'Einzelne Items:', disabled = true }) -- Einzelne Items zum Menü hinzufügen for slot, item in pairs(items) do if item and item.amount and item.amount > 0 then table.insert(menuOptions, { title = (item.label or item.name), description = 'Anzahl: ' .. item.amount .. ' | Slot: ' .. slot, icon = 'trash', onSelect = function() confirmDestroySingle(item.name, item.amount, slot) end }) end end lib.registerContext({ id = 'shredder_menu', title = '🗑️ Müllschredder Verwaltung', options = menuOptions }) lib.showContext('shredder_menu') end) -- Einzelnes Item vernichten bestätigen function confirmDestroySingle(itemName, amount, slot) lib.registerContext({ id = 'shred_single_confirm', title = '⚠️ Item vernichten?', options = { { title = '🔥 Ja, vernichten', description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!', icon = 'check', onSelect = function() -- Get the entity player is targeting for the unique ID local entity = exports['qb-target']:GetCurrentEntity() if entity and DoesEntityExist(entity) then local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) TriggerServerEvent('shredder:server:destroySingle', itemName, amount, slot, shredderID) end end }, { title = '❌ Abbrechen', description = 'Zurück zum Hauptmenü', icon = 'times', onSelect = function() -- Get the entity player is targeting for the unique ID local entity = exports['qb-target']:GetCurrentEntity() if entity and DoesEntityExist(entity) then local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) TriggerServerEvent('shredder:server:getItems', shredderID) end end } } }) lib.showContext('shred_single_confirm') end -- Alle Items vernichten bestätigen function confirmDestroyAll() lib.registerContext({ id = 'shred_all_confirm', title = '⚠️ WARNUNG ⚠️', options = { { title = '🔥 JA, ALLES VERNICHTEN', description = 'ALLE Items im Schredder werden permanent gelöscht!', icon = 'fire', onSelect = function() -- Get the entity player is targeting for the unique ID local entity = exports['qb-target']:GetCurrentEntity() if entity and DoesEntityExist(entity) then local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) TriggerServerEvent('shredder:server:destroyAll', shredderID) end end }, { title = '❌ Abbrechen', description = 'Zurück zum Hauptmenü', icon = 'times', onSelect = function() -- Get the entity player is targeting for the unique ID local entity = exports['qb-target']:GetCurrentEntity() if entity and DoesEntityExist(entity) then local model = GetEntityModel(entity) local entityCoords = GetEntityCoords(entity) local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z) TriggerServerEvent('shredder:server:getItems', shredderID) end end } } }) lib.showContext('shred_all_confirm') end -- Erfolgs-Notification mit Effekt RegisterNetEvent('shredder:client:itemDestroyed', function(message) lib.notify({ title = 'Müllschredder', description = message, type = 'success', duration = 4000 }) -- Partikel-Effekt local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) RequestNamedPtfxAsset("core") while not HasNamedPtfxAssetLoaded("core") do Wait(1) end UseParticleFxAssetNextCall("core") StartParticleFxNonLoopedAtCoord("ent_sht_steam", coords.x, coords.y, coords.z + 1.0, 0.0, 0.0, 0.0, 2.0, false, false, false) -- Sound Effect PlaySoundFrontend(-1, "CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", 1) end)