1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-25 01:55:50 +02:00
parent 7038c11f51
commit 92c426369b
7 changed files with 146 additions and 1 deletions

View file

@ -0,0 +1,91 @@
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,23 @@
fx_version 'cerulean'
game 'gta5'
name 'qb-hookah'
description 'Hookah Smoking System'
version '1.0.0'
shared_script '@qb-core/import.lua'
client_scripts {
'@qb-target/client.lua',
'@ox_lib/init.lua',
'client/main.lua'
}
server_script 'server/main.lua'
files {
'stream/props.ytyp',
'stream/hookah_prop.*'
}
data_file 'DLC_ITYP_REQUEST' 'stream/props.ytyp'

View file

@ -0,0 +1,13 @@
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,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<CBaseArchetypeDef xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<flags value="0" />
<loadedShaderGroup value="0" />
<!-- Nutzt Standard-GTA-Texturen -->
<textureDictionaries />
<!-- Props umgekehrt zugewiesen: -->
<drawableDictionaries>
<Item>prop_bong_01</Item> <!-- Wird als Hookah-Ständer verwendet -->
<Item>prop_x17_res_01</Item> <!-- Enthält v_corp_lngestoolfd (als Bong genutzt) -->
</drawableDictionaries>
<!-- Hitbox angepasst für bessere Platzierung -->
<bbMin x="-0.8" y="-0.8" z="-0.2" /> <!-- Breitere Basis für den Ständer -->
<bbMax x="0.8" y="0.8" z="1.5" /> <!-- Höhere Reichweite für Animationen -->
<!-- Pivotpunkt zentriert -->
<pivot x="0" y="0" z="0" />
<pivotRotation x="0" y="0" z="0" />
</CBaseArchetypeDef>