1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-25 03:04:57 +02:00
parent a0175cbe69
commit 1c20ce80a1
3 changed files with 51 additions and 107 deletions

View file

@ -5,39 +5,39 @@ local function Debug(msg)
print("^2[Shisha Debug] ^7" .. msg)
end
-- Check if qb-target is available
-- Überprüfen, ob qb-target verfügbar ist
CreateThread(function()
Wait(1000)
Debug("Checking if qb-target is available...")
Debug("Überprüfe, ob qb-target verfügbar ist...")
if exports['qb-target'] then
Debug("qb-target export is available")
Debug("qb-target Export ist verfügbar")
else
Debug("ERROR: qb-target export is NOT available!")
Debug("FEHLER: qb-target Export ist NICHT verfügbar!")
end
end)
-- Check if the model is valid and can be loaded
-- Überprüfen, ob das Modell gültig ist und geladen werden kann
CreateThread(function()
Debug("Checking prop model hash...")
Debug("Überprüfe Prop-Modell-Hash...")
local modelName = "prop_bong_01"
local modelHash = GetHashKey(modelName)
Debug(modelName .. " hash: " .. modelHash)
Debug(modelName .. " Hash: " .. modelHash)
if IsModelValid(modelHash) then
Debug("Model is valid!")
Debug("Modell ist gültig!")
else
Debug("Model is NOT valid!")
Debug("Modell ist NICHT gültig!")
end
if IsModelInCdimage(modelHash) then
Debug("Model is in CD image!")
Debug("Modell ist im CD-Image!")
else
Debug("Model is NOT in CD image!")
Debug("Modell ist NICHT im CD-Image!")
end
-- Try to load the model
-- Versuche, das Modell zu laden
RequestModel(modelHash)
local timeout = 0
while not HasModelLoaded(modelHash) and timeout < 50 do
@ -46,21 +46,21 @@ CreateThread(function()
end
if HasModelLoaded(modelHash) then
Debug("Model loaded successfully!")
Debug("Modell erfolgreich geladen!")
else
Debug("Model failed to load after " .. timeout * 100 .. "ms!")
Debug("Modell konnte nach " .. timeout * 100 .. "ms nicht geladen werden!")
end
end)
-- Register target for model
-- Registriere Target für Modell
CreateThread(function()
Debug("Registering target for models...")
Debug("Registriere Target für Modelle...")
-- Try both string and hash methods
-- Versuche sowohl String- als auch Hash-Methoden
local modelName = "prop_bong_01"
local modelHash = GetHashKey(modelName)
-- Method 1: Using string
-- Methode 1: Mit String
exports['qb-target']:AddTargetModel(modelName, {
options = {
{
@ -73,9 +73,9 @@ CreateThread(function()
},
distance = 2.0
})
Debug("Target registered for model string: " .. modelName)
Debug("Target für Modell-String registriert: " .. modelName)
-- Method 2: Using hash
-- Methode 2: Mit Hash
exports['qb-target']:AddTargetModel(modelHash, {
options = {
{
@ -88,77 +88,30 @@ CreateThread(function()
},
distance = 2.0
})
Debug("Target registered for model hash: " .. modelHash)
end)
-- Create props at specific locations if needed
CreateThread(function()
if Config.SpawnProps then
Debug("Creating shisha props at defined locations...")
for i, location in ipairs(Config.ShishaLocations) do
local modelHash = GetHashKey("prop_bong_01")
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Wait(10)
end
local obj = CreateObject(modelHash, location.coords.x, location.coords.y, location.coords.z - 1.0, false, false, false)
SetEntityHeading(obj, location.heading)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
exports['qb-target']:AddTargetEntity(obj, {
options = {
{
num = 1,
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen (Entity)',
}
},
distance = 2.0
})
Debug("Created shisha prop #" .. i .. " at " .. json.encode(location.coords))
end
end
end)
-- Add box zones as a fallback
CreateThread(function()
if Config.UseBoxZones then
Debug("Setting up box zones for shisha locations...")
for i, location in ipairs(Config.ShishaLocations) do
exports['qb-target']:AddBoxZone("shisha_"..i, location.coords, 0.75, 0.75, {
name = "shisha_"..i,
heading = location.heading,
debugPoly = Config.DebugPoly,
minZ = location.coords.z - 0.5,
maxZ = location.coords.z + 0.5
}, {
options = {
{
num = 1,
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen (Zone)',
}
},
distance = 2.0
})
Debug("Created box zone for shisha #" .. i)
end
Debug("Target für Modell-Hash registriert: " .. modelHash)
-- Registriere alle konfigurierten Shisha-Props
for _, propName in ipairs(Config.ShishaProps) do
exports['qb-target']:AddTargetModel(propName, {
options = {
{
num = 1,
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen',
}
},
distance = 2.0
})
Debug("Target für Modell registriert: " .. propName)
end
end)
-- Event Handler für das Öffnen des Menüs
RegisterNetEvent('nordi_shisha:client:OpenMenu')
AddEventHandler('nordi_shisha:client:OpenMenu', function()
Debug("Opening menu...")
Debug("Öffne Menü...")
OpenShishaMenu()
end)
@ -191,7 +144,7 @@ function ShowMissingIngredientsWarning(missingItems)
end
function OpenShishaMenu()
Debug("Building menu options...")
Debug("Erstelle Menüoptionen...")
local options = {}
for _, shisha in ipairs(Config.ShishaOptions) do
@ -220,7 +173,7 @@ function OpenShishaMenu()
})
end
Debug("Showing menu...")
Debug("Zeige Menü...")
lib.registerContext({
id = 'shisha_menu',
title = 'Shisha',
@ -231,7 +184,7 @@ function OpenShishaMenu()
end
function PrepareAndSmokeShisha(selectedShisha)
Debug("Starting shisha preparation...")
Debug("Starte Shisha-Vorbereitung...")
local player = PlayerPedId()
local animDict = "anim@heists@humane_labs@finale@keycards"
local anim = "ped_a_enter_loop"
@ -251,12 +204,12 @@ function PrepareAndSmokeShisha(selectedShisha)
anim = anim,
flags = 49,
}, {}, {}, function() -- Erfolg
Debug("Shisha preparation successful, triggering server event...")
Debug("Shisha-Vorbereitung erfolgreich, löse Server-Event aus...")
TriggerServerEvent('shisha-script:consumeTobacco', selectedShisha.requires)
-- Nach erfolgreicher Vorbereitung direkt rauchen
SmokeShisha(selectedShisha)
end, function() -- Abgebrochen
Debug("Shisha preparation cancelled")
Debug("Shisha-Vorbereitung abgebrochen")
QBCore.Functions.Notify("Vorbereitung abgebrochen", "error")
end)
end