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

View file

@ -1,22 +1,13 @@
Config = {} Config = {}
-- Debug mode -- Debug-Modus
Config.DebugPoly = false -- Set to true to see box zones Config.DebugPoly = false -- Auf true setzen, um Box-Zonen zu sehen
-- Prop spawning options
Config.SpawnProps = true -- Set to true to spawn props at locations
Config.UseBoxZones = true -- Set to true to use box zones as fallback
-- Welche Props sollen als Shisha funktionieren? -- Welche Props sollen als Shisha funktionieren?
Config.ShishaProps = { Config.ShishaProps = {
"prop_bong_01", -- String format "sf_prop_sf_g_bong_01a",
} "prop_bong_01",
-- Hier weitere Prop-Modelle hinzufügen
-- Locations for shishas (used for box zones and prop spawning)
Config.ShishaLocations = {
{coords = vector3(-1390.84, -605.84, 30.32), heading = 125.0}, -- Example location
{coords = vector3(1543.35, 6332.02, 24.08), heading = 42.0}, -- Example location
-- Add more locations as needed
} }
-- Progressbar Dauer in ms -- Progressbar Dauer in ms

View file

@ -7,7 +7,7 @@ end
RegisterNetEvent('shisha-script:consumeTobacco') RegisterNetEvent('shisha-script:consumeTobacco')
AddEventHandler('shisha-script:consumeTobacco', function(requirements) AddEventHandler('shisha-script:consumeTobacco', function(requirements)
Debug("Consume tobacco event triggered") Debug("Tabak-Verbrauch-Event ausgelöst")
local src = source local src = source
local Player = QBCore.Functions.GetPlayer(src) local Player = QBCore.Functions.GetPlayer(src)
@ -22,7 +22,7 @@ AddEventHandler('shisha-script:consumeTobacco', function(requirements)
end end
if hasAllItems then if hasAllItems then
Debug("Player has all required items") Debug("Spieler hat alle benötigten Items")
-- Entferne die benötigten Items -- Entferne die benötigten Items
for _, requirement in ipairs(requirements) do for _, requirement in ipairs(requirements) do
Player.Functions.RemoveItem(requirement.item, requirement.amount) Player.Functions.RemoveItem(requirement.item, requirement.amount)
@ -31,7 +31,7 @@ AddEventHandler('shisha-script:consumeTobacco', function(requirements)
TriggerClientEvent('QBCore:Notify', src, "Du hast die Shisha vorbereitet!", "success") TriggerClientEvent('QBCore:Notify', src, "Du hast die Shisha vorbereitet!", "success")
else else
Debug("Player missing required items") Debug("Spieler hat nicht alle benötigten Items")
TriggerClientEvent('QBCore:Notify', src, "Du hast nicht alle benötigten Zutaten!", "error") TriggerClientEvent('QBCore:Notify', src, "Du hast nicht alle benötigten Zutaten!", "error")
end end
end end