1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-07-28 01:36:31 +02:00
parent d806040362
commit 31ddbf70b2

View file

@ -24,59 +24,299 @@ local currentType = nil
-- QB-Target zu allen passenden Props in der Welt hinzufügen -- QB-Target zu allen passenden Props in der Welt hinzufügen
Citizen.CreateThread(function() Citizen.CreateThread(function()
-- Für sofortige Schredder -- Schredder-Optionen definieren
for _, model in ipairs(shredderPropModels) do local shredderOptions = {
exports['qb-target']:AddTargetModel(model, { {
options = { type = "client",
{ event = "disposal:openInventory",
num = 1, icon = "fas fa-dumpster",
type = "client", label = "Müllschredder öffnen",
event = "disposal:openInventory", action = function(entity)
icon = "fas fa-dumpster", currentEntity = entity
label = "Müllschredder öffnen", currentType = "shredder"
action = function(entity) TriggerEvent('disposal:openInventory')
currentEntity = entity end,
currentType = "shredder" canInteract = function()
TriggerEvent('disposal:openInventory') return true
end, end,
}, },
{ {
num = 2, type = "client",
type = "client", event = "disposal:openMenu",
event = "disposal:openMenu", icon = "fas fa-fire",
icon = "fas fa-fire", label = "Items vernichten",
label = "Items vernichten", action = function(entity)
action = function(entity) currentEntity = entity
currentEntity = entity currentType = "shredder"
currentType = "shredder" TriggerEvent('disposal:openMenu')
TriggerEvent('disposal:openMenu') end,
end, canInteract = function()
} return true
}, end,
distance = 2.0 }
}) }
end
-- Für zeitverzögerte Mülltonnen - nur eine Option zum Öffnen -- Mülltonnen-Optionen definieren
for _, model in ipairs(trashBinPropModels) do local trashOptions = {
exports['qb-target']:AddTargetModel(model, { {
options = { type = "client",
{ event = "disposal:openInventory",
num = 1, icon = "fas fa-trash",
type = "client", label = "Mülltonne öffnen",
event = "disposal:openInventory", action = function(entity)
icon = "fas fa-trash", currentEntity = entity
label = "Mülltonne öffnen", currentType = "trash"
action = function(entity) TriggerEvent('disposal:openInventory')
currentEntity = entity end,
currentType = "trash" canInteract = function()
TriggerEvent('disposal:openInventory') return true
end, end,
} }
}, }
distance = 2.0
}) -- QB-Target für Schredder hinzufügen
end 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") print("^2[DISPOSAL]^7 QB-Target zu " .. #shredderPropModels .. " Schredder-Modellen und " .. #trashBinPropModels .. " Mülltonnen-Modellen hinzugefügt")
end) 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'
})
return
end
-- 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'
})
return
end
-- 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
})
end)