ed
This commit is contained in:
parent
31ddbf70b2
commit
55ce22c3de
2 changed files with 241 additions and 237 deletions
|
@ -1,12 +1,12 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Liste der Prop-Modelle für sofortige Schredder
|
||||
-- List of prop models that should be targetable as immediate shredders
|
||||
local shredderPropModels = {
|
||||
'p_secret_weapon_02',
|
||||
'prop_bin_08a'
|
||||
}
|
||||
|
||||
-- Liste der Prop-Modelle für zeitverzögerte Mülltonnen
|
||||
-- List of prop models that should be targetable as trash bins with delayed deletion
|
||||
local trashBinPropModels = {
|
||||
'prop_bin_01a',
|
||||
'prop_bin_03a',
|
||||
|
@ -18,78 +18,86 @@ local trashBinPropModels = {
|
|||
'prop_dumpster_3a'
|
||||
}
|
||||
|
||||
-- Variable zum Speichern der aktuellen Entität
|
||||
-- Variable to store the current entity being interacted with
|
||||
local currentEntity = nil
|
||||
local currentType = nil
|
||||
|
||||
-- QB-Target zu allen passenden Props in der Welt hinzufügen
|
||||
-- Add QB-Target to all matching props in the world
|
||||
Citizen.CreateThread(function()
|
||||
-- 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
|
||||
-- Add target to shredder props
|
||||
exports['qb-target']:AddTargetModel(shredderPropModels, {
|
||||
options = shredderOptions,
|
||||
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,
|
||||
}
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
|
||||
-- QB-Target für Mülltonnen hinzufügen
|
||||
-- Add target to trash bin props
|
||||
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
||||
options = trashOptions,
|
||||
options = {
|
||||
{
|
||||
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,
|
||||
},
|
||||
{
|
||||
type = "client",
|
||||
event = "disposal:openMenu",
|
||||
icon = "fas fa-clock",
|
||||
label = "Müll entsorgen",
|
||||
action = function(entity)
|
||||
currentEntity = entity
|
||||
currentType = "trash"
|
||||
TriggerEvent('disposal:openMenu')
|
||||
end,
|
||||
canInteract = function()
|
||||
return true
|
||||
end,
|
||||
}
|
||||
},
|
||||
distance = 2.0
|
||||
})
|
||||
|
||||
print("^2[DISPOSAL]^7 QB-Target zu " .. #shredderPropModels .. " Schredder-Modellen und " .. #trashBinPropModels .. " Mülltonnen-Modellen hinzugefügt")
|
||||
print("^2[DISPOSAL]^7 Added QB-Target to " .. #shredderPropModels .. " shredder models and " .. #trashBinPropModels .. " trash bin models")
|
||||
end)
|
||||
|
||||
-- Funktion zum Abrufen der Container-ID aus der Entität
|
||||
-- Function to get container ID from entity
|
||||
function GetContainerIDFromEntity(entity, type)
|
||||
if not entity or not DoesEntityExist(entity) then return nil end
|
||||
|
||||
|
@ -98,7 +106,7 @@ function GetContainerIDFromEntity(entity, type)
|
|||
return type .. "_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
|
||||
end
|
||||
|
||||
-- Container-Inventar öffnen
|
||||
-- Open container inventory
|
||||
RegisterNetEvent('disposal:openInventory', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
@ -112,49 +120,46 @@ RegisterNetEvent('disposal:openInventory', function()
|
|||
return
|
||||
end
|
||||
|
||||
-- Container-ID abrufen
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Inventar mit dieser eindeutigen ID öffnen
|
||||
-- Open inventory with this unique ID
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Vernichtungsmenü öffnen (nur für Schredder)
|
||||
-- Open disposal menu
|
||||
RegisterNetEvent('disposal:openMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
if not currentEntity or not DoesEntityExist(currentEntity) or currentType ~= "shredder" then
|
||||
if not currentEntity or not DoesEntityExist(currentEntity) then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
title = currentType == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = currentType == "shredder" and 'Kein Schredder gefunden!' or 'Keine Mülltonne gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Container-ID abrufen
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Items in diesem Container abrufen
|
||||
-- Get items in this container
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Menü mit Items anzeigen (nur für Schredder)
|
||||
-- Show menu with items
|
||||
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
|
||||
-- Make sure items is a table
|
||||
items = items or {}
|
||||
|
||||
-- Prüfen, ob items leer ist
|
||||
-- Check if items is empty
|
||||
if next(items) == nil then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Der Schredder ist leer!',
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Die Mülltonne ist leer!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -162,23 +167,40 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
local menuOptions = {}
|
||||
|
||||
-- Alle Items vernichten Option
|
||||
-- All items action option
|
||||
local actionText = type == "shredder" and "ALLE ITEMS VERNICHTEN" or "ALLE ITEMS ENTSORGEN"
|
||||
local actionDesc = type == "shredder"
|
||||
and 'Vernichtet alle Items im Schredder permanent!'
|
||||
or 'Entsorgt alle Items in der Mülltonne (automatische Löschung nach Zeit)!'
|
||||
|
||||
table.insert(menuOptions, {
|
||||
title = '🔥 ALLE ITEMS VERNICHTEN',
|
||||
description = 'Vernichtet alle Items im Schredder permanent!',
|
||||
icon = 'fire',
|
||||
title = '🔥 ' .. actionText,
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
onSelect = function()
|
||||
confirmDestroyAll(containerID)
|
||||
confirmDestroyAll(containerID, type)
|
||||
end
|
||||
})
|
||||
|
||||
-- If it's a trash bin with scheduled deletion, show the time remaining
|
||||
if type == "trash" and timeRemaining then
|
||||
local minutes = math.floor(timeRemaining / 60)
|
||||
local seconds = timeRemaining % 60
|
||||
|
||||
table.insert(menuOptions, {
|
||||
title = '⏱️ Automatische Leerung',
|
||||
description = string.format('In %d Minuten und %d Sekunden', minutes, seconds),
|
||||
disabled = true
|
||||
})
|
||||
end
|
||||
|
||||
table.insert(menuOptions, {
|
||||
title = '─────────────────',
|
||||
description = 'Einzelne Items:',
|
||||
disabled = true
|
||||
})
|
||||
|
||||
-- Einzelne Items zum Menü hinzufügen
|
||||
-- Add individual items to menu
|
||||
local hasItems = false
|
||||
for slot, item in pairs(items) do
|
||||
if item and item.amount and item.amount > 0 then
|
||||
|
@ -188,7 +210,7 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
description = 'Anzahl: ' .. item.amount .. ' | Slot: ' .. slot,
|
||||
icon = 'trash',
|
||||
onSelect = function()
|
||||
confirmDestroySingle(item.name, item.amount, slot, containerID)
|
||||
confirmDestroySingle(item.name, item.amount, slot, containerID, type)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
@ -196,8 +218,8 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
if not hasItems then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Der Schredder ist leer!',
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Die Mülltonne ist leer!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -205,25 +227,30 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
lib.registerContext({
|
||||
id = 'disposal_menu',
|
||||
title = '🗑️ Müllschredder Verwaltung',
|
||||
title = type == "shredder" and '🗑️ Müllschredder Verwaltung' or '🗑️ Mülltonne Verwaltung',
|
||||
options = menuOptions
|
||||
})
|
||||
|
||||
lib.showContext('disposal_menu')
|
||||
end)
|
||||
|
||||
-- Einzelnes Item vernichten bestätigen (nur für Schredder)
|
||||
function confirmDestroySingle(itemName, amount, slot, containerID)
|
||||
-- Confirm single item disposal
|
||||
function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
||||
local actionText = type == "shredder" and "vernichten" or "entsorgen"
|
||||
local actionDesc = type == "shredder"
|
||||
and (itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!')
|
||||
or (itemName .. ' (' .. amount .. 'x) wird entsorgt und nach Zeit gelöscht!')
|
||||
|
||||
lib.registerContext({
|
||||
id = 'dispose_single_confirm',
|
||||
title = '⚠️ Item vernichten?',
|
||||
title = '⚠️ Item ' .. actionText .. '?',
|
||||
options = {
|
||||
{
|
||||
title = '🔥 Ja, vernichten',
|
||||
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
||||
icon = 'fire',
|
||||
title = type == "shredder" and '🔥 Ja, vernichten' or '🗑️ Ja, entsorgen',
|
||||
description = actionDesc,
|
||||
icon = 'check',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, "shredder")
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, type)
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -231,7 +258,7 @@ function confirmDestroySingle(itemName, amount, slot, containerID)
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -240,18 +267,23 @@ function confirmDestroySingle(itemName, amount, slot, containerID)
|
|||
lib.showContext('dispose_single_confirm')
|
||||
end
|
||||
|
||||
-- Alle Items vernichten bestätigen (nur für Schredder)
|
||||
function confirmDestroyAll(containerID)
|
||||
-- Confirm all items disposal
|
||||
function confirmDestroyAll(containerID, type)
|
||||
local actionText = type == "shredder" and "VERNICHTEN" or "ENTSORGEN"
|
||||
local actionDesc = type == "shredder"
|
||||
and 'ALLE Items im Schredder werden permanent gelöscht!'
|
||||
or 'ALLE Items in der Mülltonne werden nach Zeit automatisch gelöscht!'
|
||||
|
||||
lib.registerContext({
|
||||
id = 'dispose_all_confirm',
|
||||
title = '⚠️ WARNUNG ⚠️',
|
||||
options = {
|
||||
{
|
||||
title = '🔥 JA, ALLES VERNICHTEN',
|
||||
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
||||
icon = 'fire',
|
||||
title = type == "shredder" and '🔥 JA, ALLES VERNICHTEN' or '🗑️ JA, ALLES ENTSORGEN',
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeAll', containerID, "shredder")
|
||||
TriggerServerEvent('disposal:server:disposeAll', containerID, type)
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -259,7 +291,7 @@ function confirmDestroyAll(containerID)
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +300,7 @@ function confirmDestroyAll(containerID)
|
|||
lib.showContext('dispose_all_confirm')
|
||||
end
|
||||
|
||||
-- Erfolgs-Notification mit Effekt
|
||||
-- Success notification with effect
|
||||
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
|
@ -277,7 +309,7 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
duration = 4000
|
||||
})
|
||||
|
||||
-- Partikel-Effekt
|
||||
-- Particle effect
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
|
@ -288,35 +320,14 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
|
||||
UseParticleFxAssetNextCall("core")
|
||||
|
||||
-- Unterschiedliche Effekte je nach Typ
|
||||
-- Different effects for shredder vs trash
|
||||
if type == "shredder" then
|
||||
-- Intensiverer Effekt für Schredder
|
||||
-- More intense effect for shredder
|
||||
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
|
||||
-- Subtle effect for trash
|
||||
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
|
||||
})
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue