efilnikufecin
Member
So many scripts contain
I have seen many scripts which can lock into an infinite loop if a buffbot is down,
or a duplicate 1 a day buff is requested. Here is a function which shows a way of limiting the wait for a buff. In this example, if you have the skill Ode to Booze, you take care of it yourself, but when you don't it purchases the buff from Testudinata.
Things to notice:
*count can be 1 or 2, this allows the same function to be used 2 times to request ode. Once at the begining of the day, and again at the end of the day. The end of the day should carry over, but sometimes things go wrong.
*iterations is a counter. It counts the number of times the loop loops. The
statement puts a 26 time limit on the number of times the loop can occur, then it will carry on as if the buff were recieved. 26 may not be enough, but not having a limit can leave the script in an infinite loop. Instead of using break, you could use cli_execute("abort Error: Ode To Booze Not Recieved!"); which would stop the script entirely.
If someone wanted to, additions could be made to attempt to purchase from another buffbot if the first fails.
Edit: April 18, 2006 another thing to note. using a higher amount of time for the wait command results in lower processor time usage, and fewer hits on KOL's servers. Using a lower wait time may result in the scipt pulling out of the loop, and carrying on much faster. Ultimately you should make a reasonable decision based on you own situation.
Code:
while( have_effect($effect[ode to booze]) < 1)
{
cli_execute("wait 120");
cli_execute("effects refresh");
}
I have seen many scripts which can lock into an infinite loop if a buffbot is down,

Code:
void CheckOde(int count)
//possibly have a boolean return in the future
{
int iterations;
if(have_skill($skill[The Ode To Booze]))
{
if(have_effect($effect[Ode To Booze]) < 1)
{
//must add MP testing here
use_skill(1, $skill[The Ode To Booze]);
}
}
else
{
if(have_effect($effect[Ode To Booze]) < 1)
{
if (count == 1)
cli_execute("send 1 meat to Testudinata");
if (count == 2)
cli_execute("send 11 meat to Testudinata");
iterations = 0;
while( have_effect($effect[ode to booze]) < 1)
{
if (iterations > (25))
Break;
cli_execute("wait 120");
cli_execute("effects refresh");
iterations = (iterations + 1);
}
}
}
}
//end void CheckOde
Things to notice:
*count can be 1 or 2, this allows the same function to be used 2 times to request ode. Once at the begining of the day, and again at the end of the day. The end of the day should carry over, but sometimes things go wrong.
*iterations is a counter. It counts the number of times the loop loops. The
Code:
if (iterations > 25)
Break();
If someone wanted to, additions could be made to attempt to purchase from another buffbot if the first fails.
Edit: April 18, 2006 another thing to note. using a higher amount of time for the wait command results in lower processor time usage, and fewer hits on KOL's servers. Using a lower wait time may result in the scipt pulling out of the loop, and carrying on much faster. Ultimately you should make a reasonable decision based on you own situation.