Smoking animation need help

Im using this for smoking but player ped is taking the cigarette to the left hand but animation of the smoking is doint with right hand can somone help me for a better animation or can i change the hand of this cigarette object?


RegisterNetEvent('esx_basicneeds:sigara')
AddEventHandler('esx_basicneeds:sigara', function(prop_name)
	if not IsAnimated then
		prop_name = prop_name or 'ng_proc_cigarette01a'
		IsAnimated = true

		Citizen.CreateThread(function()
			local playerPed = PlayerPedId()
			local x,y,z = table.unpack(GetEntityCoords(playerPed))
			local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true)
			local boneIndex = GetPedBoneIndex(playerPed, 18905)
			AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)

			ESX.Streaming.RequestAnimDict('switch@michael@smoking', function()
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'switch@michael@smoking', 'michael_smoking_loop', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				IsAnimated = false
				ClearPedSecondaryTask(playerPed)
				DeleteObject(prop)
			end)
		end)

	end
end)
1 Like

EDIT: You could just use the animation i am using, believe it smokes with the right hand, If you want to change where the Cigarette is change this:

AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)

and find the correct bone to put in on using the bone index here: https://pastebin.com/D7JMnX1g
I us this to get the bone

GetEntityBoneIndexByName(ped, "BONETAG_R_FINGER11"), 0.0, 0.0, -0.01, 0.0, 0.0, 70.0, 0, 0, 0, 0, 0, 1)

local anim2Dict = "amb@world_human_aa_smoke@male@idle_a" --smoking joint anim dict
local anim2Name = "idle_a" --smoking joint anim name

thanks for the answer but i couldnt find where should i put that command in my lua or can you send me the all of the lines about that smoking side of this script like i do on the thread.

GetEntityBoneIndexByName(ped, "BONETAG_R_FINGER11"), 0.0, 0.0, -0.01, 0.0, 0.0, 70.0, 0, 0, 0, 0, 0, 1)

where should i put this command or if i should change with one line which one is this?

mine is here

RegisterNetEvent('esx_basicneeds:sigara')
AddEventHandler('esx_basicneeds:sigara', function(prop_name)
	if not IsAnimated then
		prop_name = prop_name or 'ng_proc_cigarette01a'
		IsAnimated = true

		Citizen.CreateThread(function()
			local playerPed = PlayerPedId()
			local x,y,z = table.unpack(GetEntityCoords(playerPed))
			local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true)
			local boneIndex = GetPedBoneIndex(playerPed, 18905)
			AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)

and i tried to edit with your codes like that but still there is no cigaret xd

RegisterNetEvent('esx_basicneeds:sigara')
AddEventHandler('esx_basicneeds:sigara', function(prop_name)
	if not IsAnimated then
		prop_name = prop_name or 'ng_proc_cigarette01a'
		IsAnimated = true

		Citizen.CreateThread(function()
			local playerPed = PlayerPedId()
			local x,y,z = table.unpack(GetEntityCoords(playerPed))
			local prop = CreateObject(GetHashKey(prop_name), x, y, z, true, true, true)
			local boneIndex = GetPedBoneIndex(ped, "BONETAG_R_FINGER11"), 0.0, 0.0, -0.01, 0.0, 0.0, 70.0, 0, 0, 0, 0, 0, 1
			AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)

			ESX.Streaming.RequestAnimDict('amb@world_human_aa_smoke@male@idle_a', function()
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				IsAnimated = false
				ClearPedSecondaryTask(playerPed)
				DeleteObject(prop)
			end)
		end)

	end
end)

prop_name = prop_name or 'ng_proc_cigarette01a'

Have you made a mistake there? should this not be

prop_name = 'ng_proc_cigarette01a'

Try this, Ive not tested it but it should do the job:

RegisterNetEvent('esx_basicneeds:sigara')
AddEventHandler('esx_basicneeds:sigara', function(prop_name)
	if not IsAnimated then
		propsigara = 'ng_proc_cigarette01a'
		IsAnimated = true

		Citizen.CreateThread(function()
			local playerPed = PlayerPedId()
			local x,y,z = table.unpack(GetEntityCoords(playerPed))
			local prop = CreateObject(GetHashKey(propSigara), x, y, z, true, true, true)

			ESX.Streaming.RequestAnimDict('amb@world_human_aa_smoke@male@idle_a', function()
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
                AttachEntityToEntity(propsigara, playerPed, GetEntityBoneIndexByName(ped, "BONETAG_R_FINGER11"), 0.0, 0.0, -0.01, 0.0, 0.0, 70.0, 0, 0, 0, 0, 0, 1)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				TaskPlayAnim(playerPed, 'amb@world_human_aa_smoke@male@idle_a', 'idle_a', 1.0, -1.0, 2000, 0, 1, true, true, true)
				Citizen.Wait(5000)
				IsAnimated = false
				ClearPedSecondaryTask(playerPed)
				DeleteObject(propsigara)
			end)
		end)

	end
end)

Still there is no cigarette in my hand. If we need the name of the item name in database it is cigarett. But like say animation works but there is no cigarette in the hand…

try to use here

	Citizen.CreateThread(function()
		local playerPed = PlayerPedId()
		local x,y,z = table.unpack(GetEntityCoords(playerPed))
		local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true)
		local boneIndex = GetPedBoneIndex(playerPed, 18905)
		AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)
		
		ESX.Streaming.RequestAnimDict('amb@world_human_aa_smoke@male@idle_a', function()
			TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_SMOKING', 0, false)

			Citizen.Wait(3000)
			IsAnimated = false
			ClearPedSecondaryTask(playerPed)
			DeleteObject(prop)
		end)
	end)

im trying to get the one were he pulls out a cig and lights it instead of it just apearing in his hand