xakingas Posted December 25, 2018 Share Posted December 25, 2018 (edited) Hello and happy Christmas everyone, I'm really new on scripting and started to make my first script (simple power fisher). After coding the basis I tried to run the script on a test account, but after the login handler logs in the account, the client pretty much freezes and processor goes 100%, anyone has an idea where I messed up? I think I'm returning something somewhere where I shouldn't Edited December 26, 2018 by xakingas Quote Link to comment Share on other sites More sharing options...
extatus Posted December 26, 2018 Share Posted December 26, 2018 (edited) the scriptmanifest has a missing parameter logo version = 0, logo = "") more: getAnimation == -1 is same as !if(myPlayer().isAnimating() { i would avoid returning the value 444 or anything else than 0, the script needs to work like clockwork because logic will break + the bot will be sluggish (it adds up weird pattern characteristics on top ) use conditional sleeps on condition, static sleeps are more or less used for debugging conditional sleeps make sure that if your latency spikes or irrelevant event occurs, ur script still sleeps --> very until the condition is done Edited December 26, 2018 by extatus Quote Link to comment Share on other sites More sharing options...
Script Kid Posted December 26, 2018 Share Posted December 26, 2018 6 hours ago, xakingas said: After coding the basis I tried to run the script on a test account, but after the login handler logs in the account, the client pretty much freezes and processor goes 100%, anyone has an idea where I messed up? I'm not sure if this will fix the problem but you should't have a variable holding the inventory instance. Just get the inventory instance every time you need to use it. And fishing spots are npcs, not objects. 6 hours ago, extatus said: i would avoid returning the value 444 or anything else than 0, the script needs to work like clockwork because logic will break 1 Quote Link to comment Share on other sites More sharing options...
Hayase Posted December 26, 2018 Share Posted December 26, 2018 Your inv variable is not in the proper scope of your script. You are checking if the inventory is full in your onloop, but your inv variable is outside of the onloop, maybe it's right but it looks wrong to me. Also you are using a while loop which is frowned upon because your onloop is already an endless loop. Two endless loops is redundant. All you need to do is check if your player is animating there is a function. myPlayer().isAnimating() I think. The way I would do it would be this: if (!myPlayer().isAnimating()) { RS2Object Bubul = getObjects().closest(1530);//bubbles if (Bubul != null) { Bubul.interact("Net"); new ConditionalSleep(5_000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } Quote Link to comment Share on other sites More sharing options...
extatus Posted December 26, 2018 Share Posted December 26, 2018 4 hours ago, Script Kid said: I'm not sure if this will fix the problem but you should't have a variable holding the inventory instance. Just get the inventory instance every time you need to use it. And fishing spots are npcs, not objects. Just to clarify, as i posted that in 5 am. :lol: As Haysae mentioned, the onLoop is already an endless loop. If your script breaks to ping fluctuation or script not looping perfectly, using >0 return values means artificially recreating slugginess that is completely unnecessary. If the script skips lines, it mightn't find your condition on the first try. On top of that, if the script were fairly simple and did 1-2 actions before naturally looping again, the outcome would be sluggy anyway. Quote Link to comment Share on other sites More sharing options...
xakingas Posted December 26, 2018 Author Share Posted December 26, 2018 9 hours ago, Script Kid said: I'm not sure if this will fix the problem but you should't have a variable holding the inventory instance. Just get the inventory instance every time you need to use it. And fishing spots are npcs, not objects. Thank you, the inventory was probably breaking it up, works fine now, THANKS! 1 Quote Link to comment Share on other sites More sharing options...
jca Posted December 27, 2018 Share Posted December 27, 2018 10 hours ago, xakingas said: Thank you, the inventory was probably breaking it up, works fine now, THANKS! FYI it was breaking because you're calling getInventory() before the inventory is available. Most API functions should be saved for your onLoop() as they require the game to be loaded / an account logged in to work correctly. Quote Link to comment Share on other sites More sharing options...
Script Kid Posted December 27, 2018 Share Posted December 27, 2018 On 12/26/2018 at 12:51 PM, extatus said: Just to clarify, as i posted that in 5 am. :lol: As Haysae mentioned, the onLoop is already an endless loop. If your script breaks to ping fluctuation or script not looping perfectly, using >0 return values means artificially recreating slugginess that is completely unnecessary. If the script skips lines, it mightn't find your condition on the first try. On top of that, if the script were fairly simple and did 1-2 actions before naturally looping again, the outcome would be sluggy anyway. Sorry, that is simply not true. The number returned by the onLoop method is amount of time the script executor will wait before invoking the method again. If this delay is set to 0, it will attempt to run the script as fast as possible, invoking the method as many times per second as your CPU can. Since the server updates the game at the very slow pace of 100 times per minute, having 1 ms or less delay between iterations is unnecessary, extremely inefficient, and can even cause the client to freeze (happened a few minutes ago when I tested running with 0 ms delay). Most scripting tutorials recommend adding a delay, this one included: And it was made by @Alek. Quote Link to comment Share on other sites More sharing options...
extatus Posted December 27, 2018 Share Posted December 27, 2018 1 hour ago, Script Kid said: Sorry, that is simply not true. The number returned by the onLoop method is amount of time the script executor will wait before invoking the method again. If this delay is set to 0, it will attempt to run the script as fast as possible, invoking the method as many times per second as your CPU can. Since the server updates the game at the very slow pace of 100 times per minute, having 1 ms or less delay between iterations is unnecessary, extremely inefficient, and can even cause the client to freeze (happened a few minutes ago when I tested running with 0 ms delay). Most scripting tutorials recommend adding a delay, this one included: And it was made by @Alek. I stand corrected. In that case, you're completely right . 1 Quote Link to comment Share on other sites More sharing options...