Correct me if I'm wrong, but where do you call functions: buyShot, buyMp and buffCheck in your loop???
At first: put Result:= false after "begin" in each function. Change range from 5000 to like 15000(if still won't work make path to get closer to the teleport NPC).
Also I recommend to put this:
delay(150);
//town coordinates range //buff id wich check //shot id //mp id
if user.inrange(144925, -56215, -2974, 5000) and User.Buffs.ByID(1062, buffCheck) and Inventory.User.ByID(1463, BuyShot) and Inventory.User.ByID(728, BuyMP) then begin
Print('Teleport.');
delay(1000);
Engine.SetTarget('Marianne'); ///gatekeeper
engine.dlgopen;
delay(1000);
Engine.DlgSel('Towns Areas');
delay(1000);
Engine.DlgSel('Goddard Area');
delay(1000);
Engine.DlgSel('Imperial Tomb');
delay(1000);
end;
in a function, and call this function after rbf or shopping is done.