1
0
Fork 0
forked from Simnation/Main

Update client.lua

This commit is contained in:
Nordi98 2025-06-25 03:24:46 +02:00
parent 29f3962a74
commit 1d91448884

View file

@ -1,216 +1,70 @@
local QBCore = exports['qb-core']:GetCoreObject() Config = {}
-- Debug Print Funktion -- Debug-Modus
local function Debug(msg) Config.DebugPoly = false -- Auf true setzen, um Box-Zonen zu sehen
print("^2[Shisha Debug] ^7" .. msg)
end
-- Überprüfen, ob qb-target verfügbar ist -- Welche Props sollen als Shisha funktionieren?
CreateThread(function() Config.ShishaProps = {
Wait(1000) "sf_prop_sf_g_bong_01a", -- Funktionierendes Modell
Debug("Überprüfe, ob qb-target verfügbar ist...") "prop_bong_01",
"hei_heist_sh_bong_01",
if exports['qb-target'] then "prop_hookah_01",
Debug("qb-target Export ist verfügbar") "prop_sh_bong_01",
else "v_res_m_bong",
Debug("FEHLER: qb-target Export ist NICHT verfügbar!") }
end
end)
-- Registriere Target für das funktionierende Shisha-Prop -- Progressbar Dauer in ms
CreateThread(function() Config.PrepareTime = 5000
Wait(2000) -- Warte etwas länger, um sicherzustellen, dass alles geladen ist Config.SmokeTime = 15000
Debug("Registriere Target für Shisha-Props...")
-- Registriere das funktionierende Modell
local workingModel = "sf_prop_sf_g_bong_01a"
Debug("Registriere Target für funktionierendes Modell: " .. workingModel)
exports['qb-target']:AddTargetModel(workingModel, {
options = {
{
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen',
}
},
distance = 2.0
})
Debug("Target für Modell registriert: " .. workingModel)
-- Versuche auch andere Modelle zu registrieren
for _, propName in ipairs(Config.ShishaProps) do
if propName ~= workingModel then
Debug("Versuche zusätzliches Modell zu registrieren: " .. propName)
exports['qb-target']:AddTargetModel(propName, {
options = {
{
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen',
}
},
distance = 2.0
})
end
end
end)
-- Event Handler für das Öffnen des Menüs -- Verfügbare Shisha-Optionen
RegisterNetEvent('nordi_shisha:client:OpenMenu') Config.ShishaOptions = {
AddEventHandler('nordi_shisha:client:OpenMenu', function() {
Debug("Öffne Menü...") label = "Apfel Shisha",
OpenShishaMenu() description = "Fruchtige Apfel-Shisha",
end) icon = "fa-solid fa-smoking",
requires = {
function CheckIngredients(requirements) {item = "shisha_tobacco", amount = 1},
local hasItems = true }
local missingItems = {} },
{
for _, requirement in ipairs(requirements) do label = "Minze Shisha",
local hasItem = QBCore.Functions.HasItem(requirement.item, requirement.amount) description = "Erfrischende Minz-Shisha",
if not hasItem then icon = "fa-solid fa-smoking",
hasItems = false requires = {
table.insert(missingItems, { {item = "shisha_tobacco", amount = 1},
item = requirement.item, }
required = requirement.amount },
}) {
end label = "Wassermelone Shisha",
end description = "Süße Wassermelonen-Shisha",
icon = "fa-solid fa-smoking",
return hasItems, missingItems requires = {
end {item = "shisha_tobacco", amount = 1},
}
function ShowMissingIngredientsWarning(missingItems) },
local warningText = "Fehlende Zutaten:\n" {
for _, item in ipairs(missingItems) do label = "Traube Shisha",
local itemLabel = QBCore.Shared.Items[item.item].label description = "Aromatische Trauben-Shisha",
warningText = warningText .. "- " .. itemLabel .. " (benötigt: " .. item.required .. ")\n" icon = "fa-solid fa-smoking",
end requires = {
{item = "shisha_tobacco", amount = 1},
QBCore.Functions.Notify(warningText, "error", 5000) }
end },
{
function OpenShishaMenu() label = "Blaubeere Shisha",
Debug("Erstelle Menüoptionen...") description = "Süße Blaubeeren-Shisha",
local options = {} icon = "fa-solid fa-smoking",
requires = {
for _, shisha in ipairs(Config.ShishaOptions) do {item = "shisha_tobacco", amount = 1},
local hasIngredients, missing = CheckIngredients(shisha.requires) }
local description = shisha.description .. "\n\nBenötigt:" },
{
for _, req in ipairs(shisha.requires) do label = "Doppel-Apfel Shisha",
local itemLabel = QBCore.Shared.Items[req.item].label description = "Intensive Doppel-Apfel-Shisha",
local hasItem = QBCore.Functions.HasItem(req.item, req.amount) icon = "fa-solid fa-smoking",
local status = hasItem and "~g~✓" or "~r~✗" requires = {
description = description .. "\n- " .. req.amount .. "x " .. itemLabel .. " " .. status {item = "shisha_tobacco", amount = 2},
end }
},
table.insert(options, { }
title = shisha.label,
description = description,
icon = shisha.icon,
onSelect = function()
local canMake, missingItems = CheckIngredients(shisha.requires)
if canMake then
PrepareAndSmokeShisha(shisha)
else
ShowMissingIngredientsWarning(missingItems)
end
end
})
end
Debug("Zeige Menü...")
lib.registerContext({
id = 'shisha_menu',
title = 'Shisha',
options = options
})
lib.showContext('shisha_menu')
end
function PrepareAndSmokeShisha(selectedShisha)
Debug("Starte Shisha-Vorbereitung...")
local player = PlayerPedId()
local animDict = "anim@heists@humane_labs@finale@keycards"
local anim = "ped_a_enter_loop"
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
QBCore.Functions.Progressbar("prepare_shisha", selectedShisha.label.." wird vorbereitet...", Config.PrepareTime or 5000, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = animDict,
anim = anim,
flags = 49,
}, {}, {}, function() -- Erfolg
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-Vorbereitung abgebrochen")
QBCore.Functions.Notify("Vorbereitung abgebrochen", "error")
end)
end
function SmokeShisha(selectedShisha)
local ped = PlayerPedId()
local propName = "v_corp_lngestoolfd" -- Dieses Modell wird aus dem Stream-Ordner geladen
local propBone = 28422
local propCoords = vector3(0.0, 0.0, -0.03)
local propRotation = vector3(0.0, 0.0, 0.0)
local animDict = "amb@world_human_aa_smoke@male@idle_a"
local animName = "idle_c"
RequestModel(GetHashKey(propName))
while not HasModelLoaded(GetHashKey(propName)) do
Wait(0)
end
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
local prop = CreateObject(GetHashKey(propName), 0.0, 0.0, 0.0, true, true, true)
AttachEntityToEntity(prop, ped, GetPedBoneIndex(ped, propBone), propCoords.x, propCoords.y, propCoords.z, propRotation.x, propRotation.y, propRotation.z, true, true, false, true, 1, true)
TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, 49, 0, false, false, false)
QBCore.Functions.Progressbar("smoke_shisha", selectedShisha.label.." rauchen...", Config.SmokeTime or 10000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Erfolg
ClearPedTasks(ped)
DeleteObject(prop)
TriggerEvent("evidence:client:SetStatus", "weedsmell", 300)
TriggerServerEvent('hud:server:RelieveStress', math.random(15, 25))
QBCore.Functions.Notify("Du fühlst dich entspannt...", "success")
end, function() -- Abgebrochen
ClearPedTasks(ped)
DeleteObject(prop)
end)
end
-- Debug Event
RegisterNetEvent('shisha-script:debug')
AddEventHandler('shisha-script:debug', function(msg)
Debug(msg)
end)