ed
This commit is contained in:
parent
001c206759
commit
5845490f4c
2 changed files with 264 additions and 266 deletions
|
@ -6,7 +6,7 @@ local shredderPropModels = {
|
|||
'prop_bin_08a'
|
||||
}
|
||||
|
||||
-- List of prop models that should be targetable as storage containers (formerly trash bins)
|
||||
-- List of prop models that should be targetable as trash bins with delayed deletion
|
||||
local trashBinPropModels = {
|
||||
'prop_bin_01a',
|
||||
'prop_bin_03a',
|
||||
|
@ -29,40 +29,72 @@ Citizen.CreateThread(function()
|
|||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = "disposal:openShredderInventory",
|
||||
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:openShredderMenu",
|
||||
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
|
||||
})
|
||||
|
||||
-- Add target to storage container props (formerly trash bins)
|
||||
-- Add target to trash bin props
|
||||
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
event = "disposal:openStorageInventory",
|
||||
icon = "fas fa-box-open",
|
||||
label = "Lager öffnen",
|
||||
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:openStorageMenu",
|
||||
icon = "fas fa-archive",
|
||||
label = "Items lagern",
|
||||
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 .. " storage container models")
|
||||
print("^2[DISPOSAL]^7 Added QB-Target to " .. #shredderPropModels .. " shredder models and " .. #trashBinPropModels .. " trash bin models")
|
||||
end)
|
||||
|
||||
-- Function to get container ID from entity
|
||||
|
@ -74,176 +106,60 @@ function GetContainerIDFromEntity(entity, type)
|
|||
return type .. "_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
|
||||
end
|
||||
|
||||
-- Open shredder inventory
|
||||
RegisterNetEvent('disposal:openShredderInventory', function()
|
||||
-- Open container inventory
|
||||
RegisterNetEvent('disposal:openInventory', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Find the closest shredder
|
||||
local closestEntity = nil
|
||||
local closestDistance = 3.0
|
||||
|
||||
for _, model in ipairs(shredderPropModels) do
|
||||
local hash = GetHashKey(model)
|
||||
if hash then
|
||||
local entity = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, hash, false, false, false)
|
||||
if entity ~= 0 then
|
||||
local distance = #(coords - GetEntityCoords(entity))
|
||||
if distance < closestDistance then
|
||||
closestEntity = entity
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not closestEntity 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
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(closestEntity, "shredder")
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Open inventory with this unique ID
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, "shredder")
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Open storage inventory
|
||||
RegisterNetEvent('disposal:openStorageInventory', function()
|
||||
-- Open disposal menu
|
||||
RegisterNetEvent('disposal:openMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Find the closest storage container
|
||||
local closestEntity = nil
|
||||
local closestDistance = 3.0
|
||||
|
||||
for _, model in ipairs(trashBinPropModels) do
|
||||
local hash = GetHashKey(model)
|
||||
if hash then
|
||||
local entity = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, hash, false, false, false)
|
||||
if entity ~= 0 then
|
||||
local distance = #(coords - GetEntityCoords(entity))
|
||||
if distance < closestDistance then
|
||||
closestEntity = entity
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not closestEntity then
|
||||
if not currentEntity or not DoesEntityExist(currentEntity) then
|
||||
lib.notify({
|
||||
title = 'Lager',
|
||||
description = 'Kein Lager 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
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(closestEntity, "trash")
|
||||
if not containerID then return end
|
||||
|
||||
-- Open inventory with this unique ID
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, "trash")
|
||||
end)
|
||||
|
||||
-- Open shredder menu
|
||||
RegisterNetEvent('disposal:openShredderMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Find the closest shredder
|
||||
local closestEntity = nil
|
||||
local closestDistance = 3.0
|
||||
|
||||
for _, model in ipairs(shredderPropModels) do
|
||||
local hash = GetHashKey(model)
|
||||
if hash then
|
||||
local entity = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, hash, false, false, false)
|
||||
if entity ~= 0 then
|
||||
local distance = #(coords - GetEntityCoords(entity))
|
||||
if distance < closestDistance then
|
||||
closestEntity = entity
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not closestEntity then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(closestEntity, "shredder")
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
if not containerID then return end
|
||||
|
||||
-- Get items in this container
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "shredder")
|
||||
end)
|
||||
|
||||
-- Open storage menu
|
||||
RegisterNetEvent('disposal:openStorageMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Find the closest storage container
|
||||
local closestEntity = nil
|
||||
local closestDistance = 3.0
|
||||
|
||||
for _, model in ipairs(trashBinPropModels) do
|
||||
local hash = GetHashKey(model)
|
||||
if hash then
|
||||
local entity = GetClosestObjectOfType(coords.x, coords.y, coords.z, 2.0, hash, false, false, false)
|
||||
if entity ~= 0 then
|
||||
local distance = #(coords - GetEntityCoords(entity))
|
||||
if distance < closestDistance then
|
||||
closestEntity = entity
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not closestEntity then
|
||||
lib.notify({
|
||||
title = 'Lager',
|
||||
description = 'Kein Lager gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(closestEntity, "trash")
|
||||
if not containerID then return end
|
||||
|
||||
-- Get items in this container
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, "trash")
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
||||
end)
|
||||
|
||||
-- Show menu with items
|
||||
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type)
|
||||
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type, timeRemaining)
|
||||
-- Make sure items is a table
|
||||
items = items or {}
|
||||
|
||||
-- Check if items is empty
|
||||
if next(items) == nil then
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Das Lager 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
|
||||
|
@ -252,20 +168,32 @@ 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 LAGERN"
|
||||
local actionText = type == "shredder" and "ALLE ITEMS VERNICHTEN" or "ALLE ITEMS ENTSORGEN"
|
||||
local actionDesc = type == "shredder"
|
||||
and 'Vernichtet alle Items im Schredder permanent!'
|
||||
or 'Lagert alle Items im Container!'
|
||||
or 'Entsorgt alle Items in der Mülltonne (automatische Löschung nach Zeit)!'
|
||||
|
||||
table.insert(menuOptions, {
|
||||
title = type == "shredder" and '🔥 ' .. actionText or '📦 ' .. actionText,
|
||||
title = '🔥 ' .. actionText,
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'archive',
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
onSelect = function()
|
||||
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:',
|
||||
|
@ -280,7 +208,7 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type)
|
|||
table.insert(menuOptions, {
|
||||
title = (item.label or item.name),
|
||||
description = 'Anzahl: ' .. item.amount .. ' | Slot: ' .. slot,
|
||||
icon = type == "shredder" and 'trash' or 'box',
|
||||
icon = 'trash',
|
||||
onSelect = function()
|
||||
confirmDestroySingle(item.name, item.amount, slot, containerID, type)
|
||||
end
|
||||
|
@ -290,8 +218,8 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type)
|
|||
|
||||
if not hasItems then
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
||||
description = type == "shredder" and 'Der Schredder ist leer!' or 'Das Lager 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
|
||||
|
@ -299,7 +227,7 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type)
|
|||
|
||||
lib.registerContext({
|
||||
id = 'disposal_menu',
|
||||
title = type == "shredder" and '🗑️ Müllschredder Verwaltung' or '📦 Lager Verwaltung',
|
||||
title = type == "shredder" and '🗑️ Müllschredder Verwaltung' or '🗑️ Mülltonne Verwaltung',
|
||||
options = menuOptions
|
||||
})
|
||||
|
||||
|
@ -308,19 +236,19 @@ end)
|
|||
|
||||
-- Confirm single item disposal
|
||||
function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
||||
local actionText = type == "shredder" and "vernichten" or "lagern"
|
||||
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 im Lager gespeichert!')
|
||||
or (itemName .. ' (' .. amount .. 'x) wird entsorgt und nach Zeit gelöscht!')
|
||||
|
||||
lib.registerContext({
|
||||
id = 'dispose_single_confirm',
|
||||
title = '⚠️ Item ' .. actionText .. '?',
|
||||
options = {
|
||||
{
|
||||
title = type == "shredder" and '🔥 Ja, vernichten' or '📦 Ja, lagern',
|
||||
title = type == "shredder" and '🔥 Ja, vernichten' or '🗑️ Ja, entsorgen',
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'check' or 'box',
|
||||
icon = 'check',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, type)
|
||||
end
|
||||
|
@ -341,19 +269,19 @@ end
|
|||
|
||||
-- Confirm all items disposal
|
||||
function confirmDestroyAll(containerID, type)
|
||||
local actionText = type == "shredder" and "VERNICHTEN" or "LAGERN"
|
||||
local actionText = type == "shredder" and "VERNICHTEN" or "ENTSORGEN"
|
||||
local actionDesc = type == "shredder"
|
||||
and 'ALLE Items im Schredder werden permanent gelöscht!'
|
||||
or 'ALLE Items werden im Lager gespeichert!'
|
||||
or 'ALLE Items in der Mülltonne werden nach Zeit automatisch gelöscht!'
|
||||
|
||||
lib.registerContext({
|
||||
id = 'dispose_all_confirm',
|
||||
title = type == "shredder" and '⚠️ WARNUNG ⚠️' or '📦 LAGERUNG',
|
||||
title = '⚠️ WARNUNG ⚠️',
|
||||
options = {
|
||||
{
|
||||
title = type == "shredder" and '🔥 JA, ALLES VERNICHTEN' or '📦 JA, ALLES LAGERN',
|
||||
title = type == "shredder" and '🔥 JA, ALLES VERNICHTEN' or '🗑️ JA, ALLES ENTSORGEN',
|
||||
description = actionDesc,
|
||||
icon = type == "shredder" and 'fire' or 'archive',
|
||||
icon = type == "shredder" and 'fire' or 'trash',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeAll', containerID, type)
|
||||
end
|
||||
|
@ -375,7 +303,7 @@ end
|
|||
-- Success notification with effect
|
||||
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Lager',
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
description = message,
|
||||
type = 'success',
|
||||
duration = 4000
|
||||
|
@ -392,13 +320,13 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
|
||||
UseParticleFxAssetNextCall("core")
|
||||
|
||||
-- Different effects for shredder vs storage
|
||||
-- Different effects for shredder vs trash
|
||||
if type == "shredder" then
|
||||
-- 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
|
||||
-- Subtle effect for storage
|
||||
-- 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue