forked from Simnation/Main
ed
This commit is contained in:
parent
5845490f4c
commit
92d275a753
2 changed files with 60 additions and 309 deletions
|
@ -1,26 +1,13 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- List of prop models that should be targetable as immediate shredders
|
||||
-- List of prop models that should be targetable as shredders
|
||||
local shredderPropModels = {
|
||||
'p_secret_weapon_02',
|
||||
'prop_bin_08a'
|
||||
}
|
||||
|
||||
-- List of prop models that should be targetable as trash bins with delayed deletion
|
||||
local trashBinPropModels = {
|
||||
'prop_bin_01a',
|
||||
'prop_bin_03a',
|
||||
'prop_bin_04a',
|
||||
'prop_bin_07a',
|
||||
'prop_dumpster_01a',
|
||||
'prop_dumpster_02a',
|
||||
'prop_dumpster_02b',
|
||||
'prop_dumpster_3a'
|
||||
}
|
||||
|
||||
-- Variable to store the current entity being interacted with
|
||||
local currentEntity = nil
|
||||
local currentType = nil
|
||||
|
||||
-- Add QB-Target to all matching props in the world
|
||||
Citizen.CreateThread(function()
|
||||
|
@ -34,7 +21,6 @@ Citizen.CreateThread(function()
|
|||
label = "Müllschredder öffnen",
|
||||
action = function(entity)
|
||||
currentEntity = entity
|
||||
currentType = "shredder"
|
||||
TriggerEvent('disposal:openInventory')
|
||||
end,
|
||||
canInteract = function()
|
||||
|
@ -48,7 +34,6 @@ Citizen.CreateThread(function()
|
|||
label = "Items vernichten",
|
||||
action = function(entity)
|
||||
currentEntity = entity
|
||||
currentType = "shredder"
|
||||
TriggerEvent('disposal:openMenu')
|
||||
end,
|
||||
canInteract = function()
|
||||
|
@ -59,51 +44,16 @@ Citizen.CreateThread(function()
|
|||
distance = 2.0
|
||||
})
|
||||
|
||||
-- Add target to trash bin props
|
||||
exports['qb-target']:AddTargetModel(trashBinPropModels, {
|
||||
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 Added QB-Target to " .. #shredderPropModels .. " shredder models and " .. #trashBinPropModels .. " trash bin models")
|
||||
print("^2[DISPOSAL]^7 Added QB-Target to " .. #shredderPropModels .. " shredder models")
|
||||
end)
|
||||
|
||||
-- Function to get container ID from entity
|
||||
function GetContainerIDFromEntity(entity, type)
|
||||
function GetContainerIDFromEntity(entity)
|
||||
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)
|
||||
return "shredder" .. "_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
|
||||
end
|
||||
|
||||
-- Open container inventory
|
||||
|
@ -113,19 +63,19 @@ RegisterNetEvent('disposal:openInventory', function()
|
|||
|
||||
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!',
|
||||
title = 'Müllschredder',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
local containerID = GetContainerIDFromEntity(currentEntity)
|
||||
if not containerID then return end
|
||||
|
||||
-- Open inventory with this unique ID
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID, currentType)
|
||||
TriggerServerEvent('disposal:server:openInventory', containerID)
|
||||
end)
|
||||
|
||||
-- Open disposal menu
|
||||
|
@ -135,31 +85,31 @@ RegisterNetEvent('disposal:openMenu', function()
|
|||
|
||||
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!',
|
||||
title = 'Müllschredder',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Get container ID
|
||||
local containerID = GetContainerIDFromEntity(currentEntity, currentType)
|
||||
local containerID = GetContainerIDFromEntity(currentEntity)
|
||||
if not containerID then return end
|
||||
|
||||
-- Get items in this container
|
||||
TriggerServerEvent('disposal:server:getItems', containerID, currentType)
|
||||
TriggerServerEvent('disposal:server:getItems', containerID)
|
||||
end)
|
||||
|
||||
-- Show menu with items
|
||||
RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type, timeRemaining)
|
||||
RegisterNetEvent('disposal:client:showMenu', function(items, containerID)
|
||||
-- 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 '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
|
||||
|
@ -168,32 +118,15 @@ 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)!'
|
||||
|
||||
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:',
|
||||
|
@ -210,7 +143,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 +151,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,7 +160,7 @@ 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
|
||||
})
|
||||
|
||||
|
@ -235,22 +168,17 @@ RegisterNetEvent('disposal:client:showMenu', function(items, containerID, type,
|
|||
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!')
|
||||
|
||||
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,
|
||||
title = '🔥 Ja, vernichten',
|
||||
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
||||
icon = 'check',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID, type)
|
||||
TriggerServerEvent('disposal:server:disposeSingle', itemName, amount, slot, containerID)
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -258,7 +186,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)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -268,22 +196,17 @@ function confirmDestroySingle(itemName, amount, slot, containerID, type)
|
|||
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!'
|
||||
|
||||
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)
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -291,7 +214,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)
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -301,9 +224,9 @@ function confirmDestroyAll(containerID, type)
|
|||
end
|
||||
|
||||
-- Success notification with effect
|
||||
RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
||||
RegisterNetEvent('disposal:client:itemDisposed', function(message)
|
||||
lib.notify({
|
||||
title = type == "shredder" and 'Müllschredder' or 'Mülltonne',
|
||||
title = 'Müllschredder',
|
||||
description = message,
|
||||
type = 'success',
|
||||
duration = 4000
|
||||
|
@ -320,14 +243,7 @@ RegisterNetEvent('disposal:client:itemDisposed', function(message, type)
|
|||
|
||||
UseParticleFxAssetNextCall("core")
|
||||
|
||||
-- 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 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
|
||||
-- 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)
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue