1
0
Fork 0
forked from Simnation/Main
Main/resources/[inventory]/nordi_schredder/client.lua

268 lines
9.5 KiB
Lua
Raw Normal View History

2025-07-27 05:45:43 +02:00
local QBCore = exports['qb-core']:GetCoreObject()
2025-07-27 21:33:14 +02:00
-- List of prop models that should be targetable as shredders
local shredderPropModels = {
'p_secret_weapon_02',
'prop_bin_08a',
'prop_bin_01a',
'prop_bin_03a',
'prop_bin_04a',
'prop_bin_07a',
'prop_dumpster_01a',
'prop_dumpster_02a',
'prop_dumpster_02b',
'prop_dumpster_3a'
2025-07-27 05:45:43 +02:00
}
2025-07-27 21:33:14 +02:00
-- Add QB-Target to all matching props in the world
2025-07-27 05:45:43 +02:00
Citizen.CreateThread(function()
2025-07-27 21:33:14 +02:00
-- Add target to all existing props
for _, model in ipairs(shredderPropModels) do
local modelHash = GetHashKey(model)
2025-07-27 05:45:43 +02:00
2025-07-27 21:33:14 +02:00
-- Add QB-Target to this model
exports['qb-target']:AddTargetModel(model, {
2025-07-27 05:45:43 +02:00
options = {
{
type = "client",
event = "shredder:openInventory",
icon = "fas fa-dumpster",
label = "Müllschredder öffnen",
canInteract = function()
return true
end,
},
{
type = "client",
event = "shredder:openMenu",
icon = "fas fa-fire",
label = "Items vernichten",
canInteract = function()
return true
end,
}
},
distance = 2.0
})
end
2025-07-27 21:33:14 +02:00
print("^2[SHREDDER]^7 Added QB-Target to " .. #shredderPropModels .. " shredder prop models")
2025-07-27 05:45:43 +02:00
end)
-- Schredder Inventar öffnen
RegisterNetEvent('shredder:openInventory', function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting
local entity = exports['qb-target']:GetCurrentEntity()
2025-07-27 05:45:43 +02:00
2025-07-27 21:33:14 +02:00
if not entity or not DoesEntityExist(entity) then
2025-07-27 05:45:43 +02:00
lib.notify({
title = 'Müllschredder',
2025-07-27 21:33:14 +02:00
description = 'Kein Schredder gefunden!',
2025-07-27 05:45:43 +02:00
type = 'error'
})
return
end
2025-07-27 21:33:14 +02:00
-- Get entity model and position for unique ID
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
-- Open inventory with this unique ID
TriggerServerEvent('shredder:server:openInventory', shredderID)
2025-07-27 05:45:43 +02:00
end)
-- Vernichtungsmenü öffnen
RegisterNetEvent('shredder:openMenu', function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting
local entity = exports['qb-target']:GetCurrentEntity()
2025-07-27 05:45:43 +02:00
2025-07-27 21:33:14 +02:00
if not entity or not DoesEntityExist(entity) then
2025-07-27 05:45:43 +02:00
lib.notify({
title = 'Müllschredder',
2025-07-27 21:33:14 +02:00
description = 'Kein Schredder gefunden!',
2025-07-27 05:45:43 +02:00
type = 'error'
})
return
end
2025-07-27 21:33:14 +02:00
-- Get entity model and position for unique ID
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
-- Get items in this shredder
TriggerServerEvent('shredder:server:getItems', shredderID)
2025-07-27 05:45:43 +02:00
end)
-- Menü mit Items anzeigen
RegisterNetEvent('shredder:client:showMenu', function(items)
if not items or #items == 0 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()
end
})
table.insert(menuOptions, {
title = '─────────────────',
description = 'Einzelne Items:',
disabled = true
})
-- Einzelne Items zum Menü hinzufügen
for slot, item in pairs(items) do
if item and item.amount and item.amount > 0 then
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)
end
})
end
end
lib.registerContext({
id = 'shredder_menu',
title = '🗑️ Müllschredder Verwaltung',
options = menuOptions
})
lib.showContext('shredder_menu')
end)
-- Einzelnes Item vernichten bestätigen
function confirmDestroySingle(itemName, amount, slot)
lib.registerContext({
id = 'shred_single_confirm',
title = '⚠️ Item vernichten?',
options = {
{
title = '🔥 Ja, vernichten',
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
icon = 'check',
onSelect = function()
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting for the unique ID
local entity = exports['qb-target']:GetCurrentEntity()
if entity and DoesEntityExist(entity) then
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
TriggerServerEvent('shredder:server:destroySingle', itemName, amount, slot, shredderID)
end
2025-07-27 05:45:43 +02:00
end
},
{
title = '❌ Abbrechen',
description = 'Zurück zum Hauptmenü',
icon = 'times',
onSelect = function()
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting for the unique ID
local entity = exports['qb-target']:GetCurrentEntity()
if entity and DoesEntityExist(entity) then
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
TriggerServerEvent('shredder:server:getItems', shredderID)
end
2025-07-27 05:45:43 +02:00
end
}
}
})
lib.showContext('shred_single_confirm')
end
-- Alle Items vernichten bestätigen
function confirmDestroyAll()
lib.registerContext({
id = 'shred_all_confirm',
title = '⚠️ WARNUNG ⚠️',
options = {
{
title = '🔥 JA, ALLES VERNICHTEN',
description = 'ALLE Items im Schredder werden permanent gelöscht!',
icon = 'fire',
onSelect = function()
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting for the unique ID
local entity = exports['qb-target']:GetCurrentEntity()
if entity and DoesEntityExist(entity) then
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
TriggerServerEvent('shredder:server:destroyAll', shredderID)
end
2025-07-27 05:45:43 +02:00
end
},
{
title = '❌ Abbrechen',
description = 'Zurück zum Hauptmenü',
icon = 'times',
onSelect = function()
2025-07-27 21:33:14 +02:00
-- Get the entity player is targeting for the unique ID
local entity = exports['qb-target']:GetCurrentEntity()
if entity and DoesEntityExist(entity) then
local model = GetEntityModel(entity)
local entityCoords = GetEntityCoords(entity)
local shredderID = "shredder_" .. model .. "_" .. math.floor(entityCoords.x) .. "_" .. math.floor(entityCoords.y) .. "_" .. math.floor(entityCoords.z)
TriggerServerEvent('shredder:server:getItems', shredderID)
end
2025-07-27 05:45:43 +02:00
end
}
}
})
lib.showContext('shred_all_confirm')
end
-- Erfolgs-Notification mit Effekt
RegisterNetEvent('shredder:client:itemDestroyed', function(message)
lib.notify({
title = 'Müllschredder',
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")
StartParticleFxNonLoopedAtCoord("ent_sht_steam", coords.x, coords.y, coords.z + 1.0, 0.0, 0.0, 0.0, 2.0, false, false, false)
-- Sound Effect
PlaySoundFrontend(-1, "CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", 1)
end)