2025-07-27 05:45:43 +02:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
|
2025-07-28 01:20:56 +02:00
|
|
|
-- Liste der Prop-Modelle für sofortige Schredder
|
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:20:56 +02:00
|
|
|
-- Liste der Prop-Modelle für zeitverzögerte Mülltonnen
|
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:20:56 +02:00
|
|
|
-- Variable zum Speichern der aktuellen Entität
|
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:20:56 +02:00
|
|
|
-- QB-Target zu allen passenden Props in der Welt hinzufügen
|
2025-07-27 05:45:43 +02:00
|
|
|
Citizen.CreateThread(function()
|
2025-07-28 01:36:31 +02:00
|
|
|
-- Schredder-Optionen definieren
|
|
|
|
local shredderOptions = {
|
|
|
|
{
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Mülltonnen-Optionen definieren
|
|
|
|
local trashOptions = {
|
|
|
|
{
|
|
|
|
type = "client",
|
|
|
|
event = "disposal:openInventory",
|
|
|
|
icon = "fas fa-trash",
|
|
|
|
label = "Mülltonne öffnen",
|
|
|
|
action = function(entity)
|
|
|
|
currentEntity = entity
|
|
|
|
currentType = "trash"
|
|
|
|
TriggerEvent('disposal:openInventory')
|
|
|
|
end,
|
|
|
|
canInteract = function()
|
|
|
|
return true
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- QB-Target für Schredder hinzufügen
|
|
|
|
exports['qb-target']:AddTargetModel(shredderPropModels, {
|
|
|
|
options = shredderOptions,
|
|
|
|
distance = 2.0
|
|
|
|
})
|
|
|
|
|
|
|
|
-- QB-Target für Mülltonnen hinzufügen
|
|
|
|
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
|
|
|
options = trashOptions,
|
|
|
|
distance = 2.0
|
|
|
|
})
|
|
|
|
|
|
|
|
print("^2[DISPOSAL]^7 QB-Target zu " .. #shredderPropModels .. " Schredder-Modellen und " .. #trashBinPropModels .. " Mülltonnen-Modellen hinzugefügt")
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Funktion zum Abrufen der Container-ID aus der Entität
|
|
|
|
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
|
|
|
|
|
|
|
|
-- Container-Inventar öffnen
|
|
|
|
RegisterNetEvent('disposal:openInventory', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
if not currentEntity or not DoesEntityExist(currentEntity) then
|
|
|
|
lib.notify({
|
|
|
|
title = currentType == "shredder" and 'Müllschredder' or 'Mülltonne',
|
|
|
|
description = currentType == "shredder" and 'Kein Schredder gefunden!' or 'Keine Mülltonne gefunden!',
|
|
|
|
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:36:31 +02:00
|
|
|
-- Container-ID abrufen
|
|
|
|
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
|
|
|
if not containerID then return end
|
|
|
|
|
|
|
|
-- Inventar mit dieser eindeutigen ID öffnen
|
|
|
|
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Vernichtungsmenü öffnen (nur für Schredder)
|
|
|
|
RegisterNetEvent('disposal:openMenu', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
if not currentEntity or not DoesEntityExist(currentEntity) or currentType ~= "shredder" then
|
|
|
|
lib.notify({
|
|
|
|
title = 'Müllschredder',
|
|
|
|
description = 'Kein Schredder gefunden!',
|
|
|
|
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:36:31 +02:00
|
|
|
-- Container-ID abrufen
|
|
|
|
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
|
|
|
if not containerID then return end
|
|
|
|
|
|
|
|
-- Items in diesem Container abrufen
|
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Menü mit Items anzeigen (nur für Schredder)
|
|
|
|
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type, timeRemaining)
|
|
|
|
-- Nur für Schredder fortfahren
|
|
|
|
if type ~= "shredder" then return end
|
|
|
|
|
|
|
|
-- Sicherstellen, dass items eine Tabelle ist
|
|
|
|
items = items or {}
|
|
|
|
|
|
|
|
-- Prüfen, ob items leer ist
|
|
|
|
if next(items) == nil 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(containerID)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
table.insert(menuOptions, {
|
|
|
|
title = '─────────────────',
|
|
|
|
description = 'Einzelne Items:',
|
|
|
|
disabled = true
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Einzelne Items zum Menü hinzufügen
|
|
|
|
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,
|
|
|
|
icon = 'trash',
|
|
|
|
onSelect = function()
|
|
|
|
confirmDestroySingle(item.name, item.amount, slot, containerID)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if not hasItems then
|
|
|
|
lib.notify({
|
|
|
|
title = 'Müllschredder',
|
|
|
|
description = 'Der Schredder ist leer!',
|
|
|
|
type = 'error'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
lib.registerContext({
|
|
|
|
id = 'disposal_menu',
|
|
|
|
title = '🗑️ Müllschredder Verwaltung',
|
|
|
|
options = menuOptions
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('disposal_menu')
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Einzelnes Item vernichten bestätigen (nur für Schredder)
|
|
|
|
function confirmDestroySingle(itemName, amount, slot, containerID)
|
|
|
|
lib.registerContext({
|
|
|
|
id = 'dispose_single_confirm',
|
|
|
|
title = '⚠️ Item vernichten?',
|
|
|
|
options = {
|
|
|
|
{
|
|
|
|
title = '🔥 Ja, vernichten',
|
|
|
|
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
|
|
|
icon = 'fire',
|
|
|
|
onSelect = function()
|
|
|
|
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, "shredder")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = '❌ Abbrechen',
|
|
|
|
description = 'Zurück zum Hauptmenü',
|
|
|
|
icon = 'times',
|
|
|
|
onSelect = function()
|
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('dispose_single_confirm')
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Alle Items vernichten bestätigen (nur für Schredder)
|
|
|
|
function confirmDestroyAll(containerID)
|
|
|
|
lib.registerContext({
|
|
|
|
id = 'dispose_all_confirm',
|
|
|
|
title = '⚠️ WARNUNG ⚠️',
|
|
|
|
options = {
|
|
|
|
{
|
|
|
|
title = '🔥 JA, ALLES VERNICHTEN',
|
|
|
|
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
|
|
|
icon = 'fire',
|
|
|
|
onSelect = function()
|
|
|
|
TriggerServerEvent('disposal:server:disposeAll', containerID, "shredder")
|
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title = '❌ Abbrechen',
|
|
|
|
description = 'Zurück zum Hauptmenü',
|
|
|
|
icon = 'times',
|
|
|
|
onSelect = function()
|
|
|
|
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lib.showContext('dispose_all_confirm')
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Erfolgs-Notification mit Effekt
|
|
|
|
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|
|
|
lib.notify({
|
|
|
|
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
|
|
|
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")
|
|
|
|
|
|
|
|
-- Unterschiedliche Effekte je nach Typ
|
|
|
|
if type == "shredder" then
|
|
|
|
-- Intensiverer Effekt für Schredder
|
|
|
|
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
|
|
|
|
-- Subtiler Effekt für Mülltonnen
|
|
|
|
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)
|
|
|
|
|
|
|
|
-- Informationen über zeitverzögerte Löschung anzeigen
|
|
|
|
RegisterNetEvent('disposal:client:showTrashInfo', function(deleteTime)
|
|
|
|
local days = math.floor(deleteTime / 86400)
|
|
|
|
local hours = math.floor((deleteTime % 86400) / 3600)
|
|
|
|
local minutes = math.floor((deleteTime % 3600) / 60)
|
|
|
|
|
|
|
|
local timeString = ""
|
|
|
|
if days > 0 then
|
|
|
|
timeString = days .. " Tag" .. (days > 1 and "e" or "") .. ", "
|
|
|
|
end
|
|
|
|
timeString = timeString .. hours .. " Stunde" .. (hours > 1 and "n" or "") .. ", "
|
|
|
|
timeString = timeString .. minutes .. " Minute" .. (minutes > 1 and "n" or "")
|
|
|
|
|
|
|
|
lib.notify({
|
|
|
|
title = 'Mülltonne',
|
|
|
|
description = 'Items werden in ' .. timeString .. ' automatisch gelöscht!',
|
|
|
|
type = 'info',
|
|
|
|
duration = 6000
|
|
|
|
})
|
2025-07-28 01:20:56 +02:00
|
|
|
end)
|