A practical example showing how to equip a fishing net during the casting animation. Includes prop spawning, hand attachment, animation playback, and automatic entity cleanup.
RegisterCommand('_FishingNetExample', function(source, args, rawCommand)
local player = PlayerPedId()
local coords = GetEntityCoords(player)
local prop_name = "mp005_s_posse_col_net01x"
-- Create the prop
local prop = CreateObject(GetHashKey(prop_name), coords.x, coords.y, coords.z, true, true, true)
SetEntityAsMissionEntity(prop, true, true)
AttachEntityToEntity(prop, player, GetEntityBoneIndexByName(player, "PH_L_Hand"),
0.0, 0.0, -0.45, 0.0, 0.0, 0.0, true, true, false, true, 1, true)
-- Request and play animation
RequestAnimDict("mini_games@fishing@shore")
while not HasAnimDictLoaded("mini_games@fishing@shore") do
Citizen.Wait(100)
end
TaskPlayAnim(player, "mini_games@fishing@shore", "cast",
1.0, 8.0, -1, 31, 0, false, false, false)
-- Cleanup prop when animation stops
Citizen.CreateThread(function()
while true do
Citizen.Wait(100)
if not IsEntityPlayingAnim(player, "mini_games@fishing@shore", "cast", 3) then
DeleteEntity(prop) -- Clean up the prop
break
end
end
end)
end)