forked from Simnation/Main
ed
This commit is contained in:
parent
c38aaaf599
commit
80db5aa524
3 changed files with 88 additions and 86 deletions
Binary file not shown.
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 338 KiB |
|
@ -1,41 +1,27 @@
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
-- Müllschredder Locations mit Props
|
-- List of prop models that should be targetable as shredders
|
||||||
local shredderLocations = {
|
local shredderPropModels = {
|
||||||
{
|
'p_secret_weapon_02',
|
||||||
coords = vector3(287.5, -1334.5, 29.3),
|
'prop_bin_08a',
|
||||||
heading = 0.0,
|
'prop_bin_01a',
|
||||||
prop = 'prop_dumpster_4' -- Ändere hier das Prop
|
'prop_bin_03a',
|
||||||
},
|
'prop_bin_04a',
|
||||||
{
|
'prop_bin_07a',
|
||||||
coords = vector3(148.54, 269.21, 109.97),
|
'prop_dumpster_01a',
|
||||||
heading = 90.0,
|
'prop_dumpster_02a',
|
||||||
prop = 'prop_bin_08a' -- Anderes Prop Beispiel
|
'prop_dumpster_02b',
|
||||||
}
|
'prop_dumpster_3a'
|
||||||
}
|
}
|
||||||
|
|
||||||
local createdProps = {}
|
-- Add QB-Target to all matching props in the world
|
||||||
|
|
||||||
-- Erstelle Müllschredder Props und Targets
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
for i, location in ipairs(shredderLocations) do
|
-- Add target to all existing props
|
||||||
-- Prop Model laden
|
for _, model in ipairs(shredderPropModels) do
|
||||||
local model = GetHashKey(location.prop)
|
local modelHash = GetHashKey(model)
|
||||||
RequestModel(model)
|
|
||||||
while not HasModelLoaded(model) do
|
|
||||||
Wait(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Prop erstellen
|
-- Add QB-Target to this model
|
||||||
local shredder = CreateObject(model, location.coords.x, location.coords.y, location.coords.z, false, false, false)
|
exports['qb-target']:AddTargetModel(model, {
|
||||||
SetEntityHeading(shredder, location.heading)
|
|
||||||
FreezeEntityPosition(shredder, true)
|
|
||||||
SetEntityInvincible(shredder, true)
|
|
||||||
|
|
||||||
table.insert(createdProps, shredder)
|
|
||||||
|
|
||||||
-- QB-Target hinzufügen
|
|
||||||
exports['qb-target']:AddTargetEntity(shredder, {
|
|
||||||
options = {
|
options = {
|
||||||
{
|
{
|
||||||
type = "client",
|
type = "client",
|
||||||
|
@ -59,6 +45,8 @@ Citizen.CreateThread(function()
|
||||||
distance = 2.0
|
distance = 2.0
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print("^2[SHREDDER]^7 Added QB-Target to " .. #shredderPropModels .. " shredder prop models")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Schredder Inventar öffnen
|
-- Schredder Inventar öffnen
|
||||||
|
@ -66,27 +54,25 @@ RegisterNetEvent('shredder:openInventory', function()
|
||||||
local playerPed = PlayerPedId()
|
local playerPed = PlayerPedId()
|
||||||
local coords = GetEntityCoords(playerPed)
|
local coords = GetEntityCoords(playerPed)
|
||||||
|
|
||||||
-- Prüfen ob Spieler nah genug an einem Schredder ist
|
-- Get the entity player is targeting
|
||||||
local nearShredder = false
|
local entity = exports['qb-target']:GetCurrentEntity()
|
||||||
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
|
if not entity or not DoesEntityExist(entity) then
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = 'Müllschredder',
|
title = 'Müllschredder',
|
||||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
description = 'Kein Schredder gefunden!',
|
||||||
type = 'error'
|
type = 'error'
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Schredder Inventar öffnen
|
-- Get entity model and position for unique ID
|
||||||
TriggerServerEvent('shredder:server:openInventory')
|
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)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Vernichtungsmenü öffnen
|
-- Vernichtungsmenü öffnen
|
||||||
|
@ -94,26 +80,25 @@ RegisterNetEvent('shredder:openMenu', function()
|
||||||
local playerPed = PlayerPedId()
|
local playerPed = PlayerPedId()
|
||||||
local coords = GetEntityCoords(playerPed)
|
local coords = GetEntityCoords(playerPed)
|
||||||
|
|
||||||
-- Prüfen ob Spieler nah genug an einem Schredder ist
|
-- Get the entity player is targeting
|
||||||
local nearShredder = false
|
local entity = exports['qb-target']:GetCurrentEntity()
|
||||||
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
|
if not entity or not DoesEntityExist(entity) then
|
||||||
lib.notify({
|
lib.notify({
|
||||||
title = 'Müllschredder',
|
title = 'Müllschredder',
|
||||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
description = 'Kein Schredder gefunden!',
|
||||||
type = 'error'
|
type = 'error'
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
TriggerServerEvent('shredder:server:getItems')
|
-- 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)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Menü mit Items anzeigen
|
-- Menü mit Items anzeigen
|
||||||
|
@ -179,7 +164,15 @@ function confirmDestroySingle(itemName, amount, slot)
|
||||||
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
||||||
icon = 'check',
|
icon = 'check',
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
TriggerServerEvent('shredder:server:destroySingle', itemName, amount, slot)
|
-- 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
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -187,7 +180,15 @@ function confirmDestroySingle(itemName, amount, slot)
|
||||||
description = 'Zurück zum Hauptmenü',
|
description = 'Zurück zum Hauptmenü',
|
||||||
icon = 'times',
|
icon = 'times',
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
TriggerServerEvent('shredder:server:getItems')
|
-- 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
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,15 @@ function confirmDestroyAll()
|
||||||
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
||||||
icon = 'fire',
|
icon = 'fire',
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
TriggerServerEvent('shredder:server:destroyAll')
|
-- 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
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -215,7 +224,15 @@ function confirmDestroyAll()
|
||||||
description = 'Zurück zum Hauptmenü',
|
description = 'Zurück zum Hauptmenü',
|
||||||
icon = 'times',
|
icon = 'times',
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
TriggerServerEvent('shredder:server:getItems')
|
-- 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
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,14 +265,3 @@ RegisterNetEvent('shredder:client:itemDestroyed', function(message)
|
||||||
-- Sound Effect
|
-- Sound Effect
|
||||||
PlaySoundFrontend(-1, "CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", 1)
|
PlaySoundFrontend(-1, "CHECKPOINT_PERFECT", "HUD_MINI_GAME_SOUNDSET", 1)
|
||||||
end)
|
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)
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
-- Schredder Inventar öffnen
|
-- Schredder Inventar öffnen
|
||||||
RegisterNetEvent('shredder:server:openInventory', function()
|
RegisterNetEvent('shredder:server:openInventory', function(shredderID)
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
|
|
||||||
-- Schredder Inventar öffnen (tgiann-inventory)
|
-- Schredder Inventar öffnen (tgiann-inventory)
|
||||||
exports['tgiann-inventory']:OpenInventory(src, 'stash', 'shredder_' .. src, {
|
exports['tgiann-inventory']:OpenInventory(src, 'stash', shredderID, {
|
||||||
maxweight = 50000, -- 50kg max
|
maxweight = 50000, -- 50kg max
|
||||||
slots = 20, -- 20 Slots
|
slots = 20, -- 20 Slots
|
||||||
label = 'Müllschredder'
|
label = 'Müllschredder'
|
||||||
|
@ -16,30 +16,27 @@ RegisterNetEvent('shredder:server:openInventory', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Items aus Schredder abrufen
|
-- Items aus Schredder abrufen
|
||||||
RegisterNetEvent('shredder:server:getItems', function()
|
RegisterNetEvent('shredder:server:getItems', function(shredderID)
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
|
|
||||||
-- Schredder Inventar Items abrufen
|
-- Schredder Inventar Items abrufen
|
||||||
local stashId = 'shredder_' .. src
|
local items = exports['tgiann-inventory']:GetInventory(shredderID)
|
||||||
local items = exports['tgiann-inventory']:GetInventory(stashId)
|
|
||||||
|
|
||||||
TriggerClientEvent('shredder:client:showMenu', src, items or {})
|
TriggerClientEvent('shredder:client:showMenu', src, items or {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Einzelnes Item vernichten
|
-- Einzelnes Item vernichten
|
||||||
RegisterNetEvent('shredder:server:destroySingle', function(itemName, amount, slot)
|
RegisterNetEvent('shredder:server:destroySingle', function(itemName, amount, slot, shredderID)
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
|
|
||||||
local stashId = 'shredder_' .. src
|
|
||||||
|
|
||||||
-- Item aus Schredder entfernen
|
-- Item aus Schredder entfernen
|
||||||
local success = exports['tgiann-inventory']:RemoveItemFromInventory(stashId, itemName, amount, slot)
|
local success = exports['tgiann-inventory']:RemoveItemFromInventory(shredderID, itemName, amount, slot)
|
||||||
|
|
||||||
if success then
|
if success then
|
||||||
-- Log für Admins
|
-- Log für Admins
|
||||||
|
@ -53,21 +50,20 @@ RegisterNetEvent('shredder:server:destroySingle', function(itemName, amount, slo
|
||||||
|
|
||||||
-- Menü neu laden
|
-- Menü neu laden
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
TriggerEvent('shredder:server:getItems', src)
|
TriggerEvent('shredder:server:getItems', src, shredderID)
|
||||||
else
|
else
|
||||||
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Vernichten des Items!', 'error')
|
TriggerClientEvent('QBCore:Notify', src, 'Fehler beim Vernichten des Items!', 'error')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Alle Items vernichten
|
-- Alle Items vernichten
|
||||||
RegisterNetEvent('shredder:server:destroyAll', function()
|
RegisterNetEvent('shredder:server:destroyAll', function(shredderID)
|
||||||
local src = source
|
local src = source
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
|
|
||||||
local stashId = 'shredder_' .. src
|
local items = exports['tgiann-inventory']:GetInventory(shredderID)
|
||||||
local items = exports['tgiann-inventory']:GetInventory(stashId)
|
|
||||||
|
|
||||||
if not items or next(items) == nil then
|
if not items or next(items) == nil then
|
||||||
TriggerClientEvent('QBCore:Notify', src, 'Der Schredder ist bereits leer!', 'error')
|
TriggerClientEvent('QBCore:Notify', src, 'Der Schredder ist bereits leer!', 'error')
|
||||||
|
@ -80,7 +76,7 @@ RegisterNetEvent('shredder:server:destroyAll', function()
|
||||||
-- Alle Items vernichten
|
-- Alle Items vernichten
|
||||||
for slot, item in pairs(items) do
|
for slot, item in pairs(items) do
|
||||||
if item and item.amount and item.amount > 0 then
|
if item and item.amount and item.amount > 0 then
|
||||||
local success = exports['tgiann-inventory']:RemoveItemFromInventory(stashId, item.name, item.amount, slot)
|
local success = exports['tgiann-inventory']:RemoveItemFromInventory(shredderID, item.name, item.amount, slot)
|
||||||
if success then
|
if success then
|
||||||
table.insert(destroyedItems, {name = item.name, amount = item.amount})
|
table.insert(destroyedItems, {name = item.name, amount = item.amount})
|
||||||
totalItems = totalItems + item.amount
|
totalItems = totalItems + item.amount
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue