forked from Simnation/Main
edit
This commit is contained in:
parent
7038c11f51
commit
92c426369b
7 changed files with 146 additions and 1 deletions
91
resources/[inventory]/nordi_hookah/client/main.lua
Normal file
91
resources/[inventory]/nordi_hookah/client/main.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue