ed
This commit is contained in:
parent
6c5c142a0d
commit
b02007598e
2 changed files with 186 additions and 196 deletions
|
@ -1,12 +1,12 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- List of prop models that should be targetable as immediate shredders
|
||||
-- Liste der Prop-Modelle für sofortige Schredder
|
||||
local shredderPropModels = {
|
||||
'p_secret_weapon_02',
|
||||
'prop_bin_08a'
|
||||
}
|
||||
|
||||
-- List of prop models that should be targetable as trash bins with delayed deletion
|
||||
-- Liste der Prop-Modelle für zeitverzögerte Mülltonnen
|
||||
local trashBinPropModels = {
|
||||
'prop_bin_01a',
|
||||
'prop_bin_03a',
|
||||
|
@ -18,13 +18,13 @@ local trashBinPropModels = {
|
|||
'prop_dumpster_3a'
|
||||
}
|
||||
|
||||
-- Variable to store the current entity being interacted with
|
||||
-- Variable zum Speichern der aktuellen Entität
|
||||
local currentEntity = nil
|
||||
local currentType = nil
|
||||
|
||||
-- Add QB-Target to all matching props in the world
|
||||
-- QB-Target zu allen passenden Props in der Welt hinzufügen
|
||||
Citizen.CreateThread(function()
|
||||
-- Add target to shredder props
|
||||
-- Für sofortige Schredder
|
||||
exports['qb-target']:AddTargetModel(shredderPropModels, {
|
||||
options = {
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ Citizen.CreateThread(function()
|
|||
distance = 2.0
|
||||
})
|
||||
|
||||
-- Add target to trash bin props
|
||||
-- Für zeitverzögerte Mülltonnen - nur eine Option zum Öffnen
|
||||
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
||||
options = {
|
||||
{
|
||||
|
@ -75,29 +75,15 @@ Citizen.CreateThread(function()
|
|||
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 Added QB-Target to " .. #shredderPropModels .. " shredder models and " .. #trashBinPropModels .. " trash bin models")
|
||||
print("^2[DISPOSAL]^7 QB-Target zu " .. #shredderPropModels .. " Schredder-Modellen und " .. #trashBinPropModels .. " Mülltonnen-Modellen hinzugefügt")
|
||||
end)
|
||||
|
||||
-- Function to get container ID from entity
|
||||
-- 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
|
||||
|
||||
|
@ -106,7 +92,7 @@ function GetContainerIDFromEntity(entity, type)
|
|||
return type .. "_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
|
||||
end
|
||||
|
||||
-- Open container inventory
|
||||
-- Container-Inventar öffnen
|
||||
RegisterNetEvent('disposal:openInventory', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
@ -120,46 +106,49 @@ RegisterNetEvent('disposal:openInventory', function()
|
|||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
-- Container-ID abrufen
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Open inventory with this unique ID
|
||||
-- Inventar mit dieser eindeutigen ID öffnen
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Open disposal menu
|
||||
-- Vernichtungsmenü öffnen (nur für Schredder)
|
||||
RegisterNetEvent('disposal:openMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
if not currentEntity or not DoesEntityExist(currentEntity) then
|
||||
if not currentEntity or not DoesEntityExist(currentEntity) or currentType ~= "shredder" then
|
||||
lib.notify({
|
||||
title = currentType == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = currentType == "shredder" and 'Kein Schredder gefunden!' or 'Keine Mülltonne gefunden!',
|
||||
title = 'Müllschredder',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
-- Container-ID abrufen
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Get items in this container
|
||||
-- Items in diesem Container abrufen
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Show menu with items
|
||||
-- Menü mit Items anzeigen (nur für Schredder)
|
||||
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type, timeRemaining)
|
||||
-- Make sure items is a table
|
||||
-- Nur für Schredder fortfahren
|
||||
if type ~= "shredder" then return end
|
||||
|
||||
-- Sicherstellen, dass items eine Tabelle ist
|
||||
items = items or {}
|
||||
|
||||
-- Check if items is empty
|
||||
-- Prüfen, ob items leer ist
|
||||
if next(items) == nil then
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Die Mülltonne ist leer!',
|
||||
title = 'Müllschredder',
|
||||
description = 'Der Schredder ist leer!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -167,40 +156,23 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
local menuOptions = {}
|
||||
|
||||
-- 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)!'
|
||||
|
||||
-- Alle Items vernichten Option
|
||||
table.insert(menuOptions, {
|
||||
title = '🔥 ' .. actionText,
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
title = '🔥 ALLE ITEMS VERNICHTEN',
|
||||
description = 'Vernichtet alle Items im Schredder permanent!',
|
||||
icon = 'fire',
|
||||
onSelect = function()
|
||||
confirmDestroyAll(containerID, type)
|
||||
confirmDestroyAll(containerID)
|
||||
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
|
||||
})
|
||||
|
||||
-- Add individual items to menu
|
||||
-- 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
|
||||
|
@ -210,7 +182,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, type)
|
||||
confirmDestroySingle(item.name, item.amount, slot, containerID)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
@ -218,8 +190,8 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
if not hasItems then
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Die Mülltonne ist leer!',
|
||||
title = 'Müllschredder',
|
||||
description = 'Der Schredder ist leer!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
|
@ -227,30 +199,25 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
|
||||
lib.registerContext({
|
||||
id = 'disposal_menu',
|
||||
title = type == "shredder" and '🗑️ Müllschredder Verwaltung' or '🗑️ Mülltonne Verwaltung',
|
||||
title = '🗑️ Müllschredder Verwaltung',
|
||||
options = menuOptions
|
||||
})
|
||||
|
||||
lib.showContext('disposal_menu')
|
||||
end)
|
||||
|
||||
-- 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!')
|
||||
|
||||
-- Einzelnes Item vernichten bestätigen (nur für Schredder)
|
||||
function confirmDestroySingle(itemName, amount, slot, containerID)
|
||||
lib.registerContext({
|
||||
id = 'dispose_single_confirm',
|
||||
title = '⚠️ Item ' .. actionText .. '?',
|
||||
title = '⚠️ Item vernichten?',
|
||||
options = {
|
||||
{
|
||||
title = type == "shredder" and '🔥 Ja, vernichten' or '🗑️ Ja, entsorgen',
|
||||
description = actionDesc,
|
||||
icon = 'check',
|
||||
title = '🔥 Ja, vernichten',
|
||||
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
||||
icon = 'fire',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, type)
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, "shredder")
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -258,7 +225,7 @@ function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -267,23 +234,18 @@ function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
|||
lib.showContext('dispose_single_confirm')
|
||||
end
|
||||
|
||||
-- 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!'
|
||||
|
||||
-- Alle Items vernichten bestätigen (nur für Schredder)
|
||||
function confirmDestroyAll(containerID)
|
||||
lib.registerContext({
|
||||
id = 'dispose_all_confirm',
|
||||
title = '⚠️ WARNUNG ⚠️',
|
||||
options = {
|
||||
{
|
||||
title = type == "shredder" and '🔥 JA, ALLES VERNICHTEN' or '🗑️ JA, ALLES ENTSORGEN',
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
title = '🔥 JA, ALLES VERNICHTEN',
|
||||
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
||||
icon = 'fire',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeAll', containerID, type)
|
||||
TriggerServerEvent('disposal:server:disposeAll', containerID, "shredder")
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -291,7 +253,7 @@ function confirmDestroyAll(containerID, type)
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, type)
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +262,7 @@ function confirmDestroyAll(containerID, type)
|
|||
lib.showContext('dispose_all_confirm')
|
||||
end
|
||||
|
||||
-- Success notification with effect
|
||||
-- Erfolgs-Notification mit Effekt
|
||||
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
|
@ -309,7 +271,7 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
duration = 4000
|
||||
})
|
||||
|
||||
-- Particle effect
|
||||
-- Partikel-Effekt
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
|
@ -320,14 +282,35 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
|
||||
UseParticleFxAssetNextCall("core")
|
||||
|
||||
-- Different effects for shredder vs trash
|
||||
-- Unterschiedliche Effekte je nach Typ
|
||||
if type == "shredder" then
|
||||
-- More intense effect for shredder
|
||||
-- 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
|
||||
-- Subtle effect for trash
|
||||
-- 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
|
||||
})
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue