forked from Simnation/Main
ed
This commit is contained in:
parent
c38aaaf599
commit
80db5aa524
3 changed files with 88 additions and 86 deletions
|
@ -1,41 +1,27 @@
|
|||
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
|
||||
}
|
||||
-- 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'
|
||||
}
|
||||
|
||||
local createdProps = {}
|
||||
|
||||
-- Erstelle Müllschredder Props und Targets
|
||||
-- Add QB-Target to all matching props in the world
|
||||
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
|
||||
-- Add target to all existing props
|
||||
for _, model in ipairs(shredderPropModels) do
|
||||
local modelHash = GetHashKey(model)
|
||||
|
||||
-- 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, {
|
||||
-- Add QB-Target to this model
|
||||
exports['qb-target']:AddTargetModel(model, {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
|
@ -59,6 +45,8 @@ Citizen.CreateThread(function()
|
|||
distance = 2.0
|
||||
})
|
||||
end
|
||||
|
||||
print("^2[SHREDDER]^7 Added QB-Target to " .. #shredderPropModels .. " shredder prop models")
|
||||
end)
|
||||
|
||||
-- Schredder Inventar öffnen
|
||||
|
@ -66,27 +54,25 @@ 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
|
||||
-- Get the entity player is targeting
|
||||
local entity = exports['qb-target']:GetCurrentEntity()
|
||||
|
||||
if not nearShredder then
|
||||
if not entity or not DoesEntityExist(entity) then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
end
|
||||
|
||||
-- Schredder Inventar öffnen
|
||||
TriggerServerEvent('shredder:server:openInventory')
|
||||
-- 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)
|
||||
end)
|
||||
|
||||
-- Vernichtungsmenü öffnen
|
||||
|
@ -94,26 +80,25 @@ 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
|
||||
-- Get the entity player is targeting
|
||||
local entity = exports['qb-target']:GetCurrentEntity()
|
||||
|
||||
if not nearShredder then
|
||||
if not entity or not DoesEntityExist(entity) then
|
||||
lib.notify({
|
||||
title = 'Müllschredder',
|
||||
description = 'Du bist zu weit vom Schredder entfernt!',
|
||||
description = 'Kein Schredder gefunden!',
|
||||
type = 'error'
|
||||
})
|
||||
return
|
||||
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)
|
||||
|
||||
-- Menü mit Items anzeigen
|
||||
|
@ -179,7 +164,15 @@ function confirmDestroySingle(itemName, amount, slot)
|
|||
description = itemName .. ' (' .. amount .. 'x) wird permanent gelöscht!',
|
||||
icon = 'check',
|
||||
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
|
||||
},
|
||||
{
|
||||
|
@ -187,7 +180,15 @@ function confirmDestroySingle(itemName, amount, slot)
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +208,15 @@ function confirmDestroyAll()
|
|||
description = 'ALLE Items im Schredder werden permanent gelöscht!',
|
||||
icon = 'fire',
|
||||
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
|
||||
},
|
||||
{
|
||||
|
@ -215,7 +224,15 @@ function confirmDestroyAll()
|
|||
description = 'Zurück zum Hauptmenü',
|
||||
icon = 'times',
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -248,14 +265,3 @@ RegisterNetEvent('shredder:client:itemDestroyed', function(message)
|
|||
-- 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