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)
What it does is this: when you begin fishing using task, a rod is given to the player. However, after the task is completed the rod just sits in the boat / water, so the above code is used to “clean up” any fishing rods near the player.
However, I tested this today with someone on my private server and this caused a problem: when he started the fishing job, I could see him fishing but his fishing rod was missing.
Same thing for me, he could see me fishing but no fishing rod… how would I go about fixing this?
What do you think does “GETCLOSEST” mean.
As long as there is a specific object this native will allways return the closest rod no matter how big the distance is.
Why loop it? After player’s rod is gone, it goes for the next nearest player’s rod…forever.
It shouldn’t need to loop in order to delete only 1 object, am I wrong?