forked from Simnation/Main
ed
This commit is contained in:
parent
8aa97f4f25
commit
5e82135920
3 changed files with 394 additions and 0 deletions
261
resources/[inventory]/nordi_schredder/client.lua
Normal file
261
resources/[inventory]/nordi_schredder/client.lua
Normal file
|
@ -0,0 +1,261 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Müllschredder Locations mit Props
|
||||
local shredderLocations = {
|
||||
{
|
||||
coords = vector3(287.5, -1334.5, 29.3),
|
||||
heading = 0.0,
|
||||
prop = 'prop_dumpster_4' -- Ändere hier das Prop
|
||||
},
|
||||
{
|
||||
coords = vector3(148.54, 269.21, 109.97),
|
||||
heading = 90.0,
|
||||
prop = 'prop_bin_08a' -- Anderes Prop Beispiel
|
||||
}
|
||||
}
|
||||
|
||||
local createdProps = {}
|
||||
|
||||
-- Erstelle Müllschredder Props und Targets
|
||||
Citizen.CreateThread(function()
|
||||
for i, location in ipairs(shredderLocations) do
|
||||
-- Prop Model laden
|
||||
local model = GetHashKey(location.prop)
|
||||
RequestModel(model)
|
||||
while not HasModelLoaded(model) do
|
||||
Wait(1)
|
||||
end
|
||||
|
||||
-- Prop erstellen
|
||||
local shredder = CreateObject(model, location.coords.x, location.coords.y, location.coords.z, false, false, false)
|
||||
SetEntityHeading(shredder, location.heading)
|
||||
FreezeEntityPosition(shredder, true)
|
||||
SetEntityInvincible(shredder, true)
|
||||
|
||||
table.insert(createdProps, shredder)
|
||||
|
||||
-- QB-Target hinzufügen
|
||||
exports['qb-target']:AddTargetEntity(shredder, {
|
||||
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
|
||||
end)
|
||||
|
||||
-- Schredder Inventar öffnen
|
||||
RegisterNetEvent('shredder:openInventory', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Prüfen ob Spieler nah genug an einem Schredder ist
|
||||
local nearShredder = false
|
||||
for i, location in ipairs(shredderLocations) do
|
||||
local distance = #(coords - location.coords)
|
||||
if distance <= 3.0 then
|
||||
nearShredder = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not nearShredder then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Schredder Inventar öffnen
|
||||
TriggerServerEvent('shredder:server:openInventory')
|
||||
end)
|
||||
|
||||
-- Vernichtungsmenü öffnen
|
||||
RegisterNetEvent('shredder:openMenu', function()
|
||||
local playerPed = PlayerPedId()
|
||||
local coords = GetEntityCoords(playerPed)
|
||||
|
||||
-- Prüfen ob Spieler nah genug an einem Schredder ist
|
||||
local nearShredder = false
|
||||
for i, location in ipairs(shredderLocations) do
|
||||
local distance = #(coords - location.coords)
|
||||
if distance <= 3.0 then
|
||||
nearShredder = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not nearShredder then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
TriggerServerEvent('shredder:server:getItems')
|
||||
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()
|
||||
TriggerServerEvent('shredder:server:destroySingle', itemName, amount, slot)
|
||||
end
|
||||
},
|
||||
{
|
||||
title = '❌ Abbrechen',
|
||||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('shredder:server:getItems')
|
||||
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()
|
||||
TriggerServerEvent('shredder:server:destroyAll')
|
||||
end
|
||||
},
|
||||
{
|
||||
title = '❌ Abbrechen',
|
||||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
onSelect = function()
|
||||
TriggerServerEvent('shredder:server:getItems')
|
||||
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)
|
||||
|
||||
-- Cleanup beim Resource Stop
|
||||
AddEventHandler('onResourceStop', function(resourceName)
|
||||
if GetCurrentResourceName() == resourceName then
|
||||
for _, prop in pairs(createdProps) do
|
||||
if DoesEntityExist(prop) then
|
||||
DeleteEntity(prop)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue