Make all the waypoints inside the cave (lets say it is wpt #1 to wpt #10)
wpt10 -- this should be the rope wpt
wpt 11 - make a stand wherever you stand to fish
ACTION1 - write inside...
wpt 12 and on -> your way back to the cave
local CapToStop = 50
local FishToStop = 10
local TimerToStop = 4*60*1000
local timer = timems
local range = 7
while cap >= CapToStop or itemcount('fish') <= FishToStop or (timems - timer) <= TimerToStop do
local i = math.random(-range,range)
local j = math.random(-range,range)
if toptileitem(posx+i,posy+j,posz) >= 4598 and toptileitem(posx+i,posy+j,posz) <= 4602 then
Kinda hard to see if it would work since you didn't describe exactly what u wanted but...
This way, it will fish until...
Cap < CapToStop
Fish Amount > FishToStop
or after a 4min timer has passed by.
Try it and tell me if it worked