1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-25 02:26:26 +02:00
parent 1f3154bce7
commit 873f9b15f7
10 changed files with 316 additions and 104 deletions

View file

@ -0,0 +1,180 @@
local QBCore = exports['qb-core']:GetCoreObject()
-- Debug Print Funktion
local function Debug(msg)
print("^2[Shisha Debug] ^7" .. msg)
end
CreateThread(function()
Debug("Script starting...")
for _, prop in pairs(Config.ShishaProps) do
exports['qb-target']:AddTargetModel(prop, {
options = {
{
num = 1,
type = "client",
event = "nordi_shisha:client:OpenMenu",
icon = 'fas fa-smoking',
label = 'Shisha rauchen',
}
},
distance = 2.0
})
end
Debug("Target options registered")
end)
-- Event Handler für das Öffnen des Menüs
RegisterNetEvent('nordi_shisha:client:OpenMenu')
AddEventHandler('nordi_shisha:client:OpenMenu', function()
Debug("Opening menu...")
OpenShishaMenu()
end)
function CheckIngredients(requirements)
local hasItems = true
local missingItems = {}
for _, requirement in ipairs(requirements) do
local hasItem = QBCore.Functions.HasItem(requirement.item, requirement.amount)
if not hasItem then
hasItems = false
table.insert(missingItems, {
item = requirement.item,
required = requirement.amount
})
end
end
return hasItems, missingItems
end
function ShowMissingIngredientsWarning(missingItems)
local warningText = "Fehlende Zutaten:\n"
for _, item in ipairs(missingItems) do
local itemLabel = QBCore.Shared.Items[item.item].label
warningText = warningText .. "- " .. itemLabel .. " (benötigt: " .. item.required .. ")\n"
end
QBCore.Functions.Notify(warningText, "error", 5000)
end
function OpenShishaMenu()
Debug("Building menu options...")
local options = {}
for _, shisha in ipairs(Config.ShishaOptions) do
local hasIngredients, missing = CheckIngredients(shisha.requires)
local description = shisha.description .. "\n\nBenötigt:"
for _, req in ipairs(shisha.requires) do
local itemLabel = QBCore.Shared.Items[req.item].label
local hasItem = QBCore.Functions.HasItem(req.item, req.amount)
local status = hasItem and "~g~✓" or "~r~✗"
description = description .. "\n- " .. req.amount .. "x " .. itemLabel .. " " .. status
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("Showing menu...")
lib.registerContext({
id = 'shisha_menu',
title = 'Shisha',
options = options
})
lib.showContext('shisha_menu')
end
function PrepareAndSmokeShisha(selectedShisha)
Debug("Starting shisha preparation...")
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 preparation successful, triggering server event...")
TriggerServerEvent('shisha-script:consumeTobacco', selectedShisha.requires)
-- Nach erfolgreicher Vorbereitung direkt rauchen
SmokeShisha(selectedShisha)
end, function() -- Abgebrochen
Debug("Shisha preparation cancelled")
QBCore.Functions.Notify("Vorbereitung abgebrochen", "error")
end)
end
function SmokeShisha(selectedShisha)
local ped = PlayerPedId()
local propName = "v_corp_lngestoolfd"
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)

View file

@ -1,91 +0,0 @@
local Config = {
HookahProp = 'prop_bong_01', -- Eigenes Prop (ohne .ydr/.ytd)
TobaccoItem = 'shisha_tobacco',
Keybind = 'E',
Animation = {
dict = 'anim@amb@clubhouse@table@male@smoking@base',
anim = 'base',
prop = 'v_corp_lngestoolfd',
flag = 49,
bone = 57005
},
SmokeEffect = {
name = 'ent_anim_cig_exhale_mth',
scale = 0.2
},
UseDuration = 30 -- Sekunden
}
local isSmoking = false
local smokeEffect = nil
-- Preload Assets
CreateThread(function()
RequestModel(Config.HookahProp)
RequestAnimDict(Config.Animation.dict)
while not HasModelLoaded(Config.HookahProp) or not HasAnimDictLoaded(Config.Animation.dict) do
Wait(0)
end
end)
-- Hookah Placement Logic
RegisterCommand('placehookah', function()
if isSmoking then return end
local playerPed = PlayerPedId()
local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 0.8, -0.4)
local heading = GetEntityHeading(playerPed)
local hookah = CreateObject(Config.HookahProp, coords.x, coords.y, coords.z, true, true, true)
PlaceObjectOnGroundProperly(hookah)
SetEntityHeading(hookah, heading)
FreezeEntityPosition(hookah, true)
exports['qb-target']:AddTargetEntity(hookah, {
options = {
{
type = 'client',
event = 'qb-hookah:startSmoking',
icon = 'fas fa-smoking',
label = 'Smoke Hookah',
targeticon = 'fas fa-eye',
item = Config.TobaccoItem
}
},
distance = 2.5
})
end, false)
-- Smoking Logic
RegisterNetEvent('qb-hookah:startSmoking', function(entity)
if isSmoking then return end
QBCore.Functions.TriggerCallback('qb-hookah:removeTobacco', function(success)
if not success then
QBCore.Functions.Notify('You need hookah tobacco!', 'error')
return
end
isSmoking = true
local playerPed = PlayerPedId()
local animDict = Config.Animation.dict
-- Attach bong prop
local bong = CreateObject(Config.Animation.prop, GetEntityCoords(playerPed), true, true, true)
AttachEntityToEntity(bong, playerPed, Config.Animation.bone, 0.12, 0.018, -0.01, -80.0, -20.0, 180.0, true, true, false, true, 1, true)
-- Play animation
TaskPlayAnim(playerPed, animDict, Config.Animation.anim, 8.0, -8.0, Config.UseDuration * 1000, Config.Animation.flag, 0, false, false, false)
-- Smoke effect
UseParticleFxAssetNextCall('core')
smokeEffect = StartParticleFxLoopedOnEntityBone(Config.SmokeEffect.name, playerPed, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, GetPedBoneIndex(playerPed, 47419), Config.SmokeEffect.scale, 0.0, 0.0, 0.0)
-- Auto stop
Wait(Config.UseDuration * 1000)
DeleteObject(bong)
StopParticleFxLooped(smokeEffect, 0)
ClearPedTasks(playerPed)
isSmoking = false
end)
end)

View file

@ -0,0 +1,62 @@
Config = {}
-- Welche Props sollen als Shisha funktionieren?
Config.ShishaProps = {
`prop_bong_01`,
}
-- Progressbar Dauer in ms
Config.PrepareTime = 5000
Config.SmokeTime = 15000
-- Verfügbare Shisha-Optionen
Config.ShishaOptions = {
{
label = "Apfel Shisha",
description = "Fruchtige Apfel-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 1},
}
},
{
label = "Minze Shisha",
description = "Erfrischende Minz-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 1},
}
},
{
label = "Wassermelone Shisha",
description = "Süße Wassermelonen-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 1},
}
},
{
label = "Traube Shisha",
description = "Aromatische Trauben-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 1},
}
},
{
label = "Blaubeere Shisha",
description = "Süße Blaubeeren-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 1},
}
},
{
label = "Doppel-Apfel Shisha",
description = "Intensive Doppel-Apfel-Shisha",
icon = "fa-solid fa-smoking",
requires = {
{item = "shisha_tobacco", amount = 2},
}
},
}

View file

@ -1,2 +1,28 @@
fx_version 'cerulean'
game 'gta5'
description 'Shisha mit qb_target'
author 'Nordi (converted)'
version '1.0.0'
shared_scripts {
'@ox_lib/init.lua',
'config.lua'
}
client_scripts {
'client.lua'
}
server_scripts {
'server.lua'
}
lua54 'yes'
dependencies {
'qb-target',
'qb-core',
'ox_lib'
}

View file

@ -0,0 +1,38 @@
local QBCore = exports['qb-core']:GetCoreObject()
-- Debug Print Funktion
local function Debug(msg)
print("^2[Shisha Debug] ^7" .. msg)
end
RegisterNetEvent('shisha-script:consumeTobacco')
AddEventHandler('shisha-script:consumeTobacco', function(requirements)
Debug("Consume tobacco event triggered")
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if Player then
-- Überprüfe nochmal die Zutaten
local hasAllItems = true
for _, requirement in ipairs(requirements) do
if not Player.Functions.HasItem(requirement.item, requirement.amount) then
hasAllItems = false
break
end
end
if hasAllItems then
Debug("Player has all required items")
-- Entferne die benötigten Items
for _, requirement in ipairs(requirements) do
Player.Functions.RemoveItem(requirement.item, requirement.amount)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[requirement.item], "remove")
end
TriggerClientEvent('QBCore:Notify', src, "Du hast die Shisha vorbereitet!", "success")
else
Debug("Player missing required items")
TriggerClientEvent('QBCore:Notify', src, "Du hast nicht alle benötigten Zutaten!", "error")
end
end
end)

View file

@ -1,13 +0,0 @@
QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateCallback('qb-hookah:removeTobacco', function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
if not Player then return cb(false) end
if Player.Functions.RemoveItem('shisha_tobacco', 1) then
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items['shisha_tobacco'], "remove")
cb(true)
else
cb(false)
end
end)

View file

@ -0,0 +1,10 @@
fx_version 'cerulean'
game 'gta5'
files {
'stream/props.ytyp'
}
data_file 'DLC_ITYP_REQUEST' 'stream/props.ytyp'
this_is_a_map 'yes'