[HELP] How to get boneindex of 2 entities? (Trying to attach fishing rod to player for animation)

I would like to know how I can go about getting the boneidex of both entities (player and fishing rod) so I can create the object (fishing rod) and then attach it to the player entity using:

CreateObject() && AttachEntityToEntity()

Can someone point me to the right direction? thank you

Can’t you add it as an addon weapon? Then you could animate it.

Anyway, here’s the BoneIndex;

BoneIndex Reference

Sorry I am not familiar with “Addon Weapon”, what would be the native for it? I tried looking for it but I can’t find anything like such :frowning: thanks

There is a fishing animation. U could use it instead.

I am using the fishing animation… It’s why I need the object since it does not have it when I use it

                       RequestAnimDict("amb")
                       RequestAnimDict("amb@world_human_stand_fishing")
                       RequestAnimDict("amb@world_human_stand_fishing@idle_a")

                       while (not HasAnimDictLoaded("amb@world_human_stand_fishing@idle_a")) do 
					   Citizen.Wait(0) 
					   end

                      TaskPlayAnim(pid,"amb@world_human_stand_fishing@idle_a","idle_a",1.0,-1.0, 5000, 0, 1, true, true, true)

It plays the animation fine, but I do NOT have a fishing rod while the animation is playing, hence the reason I want to create a fishing rod object (which I am able to do right now) and Attach the entity rod to entity player (which I am not being successful at :frowning:

If I use it, I have it :thinking:

same as the code above?

I am not sure, I am not at home rn. I will take a look at my code after arriving at home.

sooooooooooooooooooooooooo I got it working… but it’s not attaching to my hands LOL

AttachEntityToEntity(rod, player, 119, -0.5, -5.0, 1.0, 0.0, 0.0, 0.0, false, false, false, false, 20, true)

TaskStartScenarioInPlace(playerPed, "WORLD_HUMAN_STAND_FISHING", 0, false)

That is how your ped start fishing with the fishing rod.

how to you end the task? I cant seem the find a native for it

ClearPedTasksImmediately(playerPed)

One last thing thank you so much for the help :slight_smile: is there any way to delete the object created after you kill a task?

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1)
		local playerPedPos = GetEntityCoords(GetPlayerPed(-1), true)
		local fishingRod = GetClosestObjectOfType(playerPedPos, 10.0, GetHashKey("prop_fishing_rod_01"), false, false, false)
		
		if (IsPedActiveInScenario(GetPlayerPed(-1)) == false) then
			SetEntityAsMissionEntity(fishingRod, 1, 1)
			DeleteEntity(fishingRod)
		end
	end
end)

Not tested, but should work

2 Likes

Thank you, it works very well! :slight_smile:

No problem, I am glad I could help you.