Timeout during TPS drink creation causing script abort

Sako

Member
Hello,

I have a daily script that involves crafting TPS drinks. At times, during the creation of the drinks, I get a page timeout, and the script is aborted.
Goes like this -
- create 1 skewered cherry
- timeout waiting for the response page
- the skewered cherry is created, but mafia doesn't see it
- create 1 sangria del diablo
- mafia gives error "you need 1 more TPS to continue"
- script fails.

Is there any way to prevent this? I'm using Mafia 11.
 

macman104

Member
[quote author=Sako link=topic=1262.msg5855#msg5855 date=1191825349]
11.2.
[/quote]Might you see if you still have the issue with 11.7? You're quite a few version behind....
 

Sako

Member
Tried with 11.7, after a couple days happened too, but it's worse... the script doesn't abort, it goes in an endless loop.

Code:
Verifying ingredients for sangria del diablo (1)...
Verifying ingredients for sangria (1)...
Creating sangria (1)...
You acquire an item:  sangria
Successfully created sangria (1)
Verifying ingredients for skewered cherry (1)...
Creating skewered cherry (1)...
Time out during response (cocktail.php).
Creating skewered cherry (1)...
Successfully created skewered cherry (0)
Creating skewered cherry (1)...
Successfully created skewered cherry (0)
Creating skewered cherry (1)...
Successfully created skewered cherry (0)
Creating skewered cherry (1)...
Successfully created skewered cherry (0)
Creating skewered cherry (1)...
Successfully created skewered cherry (0)
Creating skewered cherry (1)...
Successfully created skewered cherry (0)

Help ç_ç
 

Sako

Member
Nope, still haven't solved the problem. The said method goes like this.
Code:
// Creates TPS drinks.
void drinkTPS()
{
  if (item_amount($item[sangria del diablo]) == 0)
  {
    if(item_amount($item[cherry]) == 0)
      buy((6 - item_amount($item[cherry])), $item[cherry]);
    if(item_amount($item[boxed wine]) == 0)
      buy((3 - item_amount($item[boxed wine])), $item[boxed wine]);
    create(1, $item[sangria del diablo]);
  }
  drink(1, $item[sangria del diablo]);
}
 

hippymon

Member
I see 1 problem.
Code:
  if(item_amount($item[cherry]) == 0)
   buy((6 - item_amount($item[cherry])), $item[cherry]);
  if(item_amount($item[boxed wine]) == 0)
   buy((3 - item_amount($item[boxed wine])), $item[boxed wine]);
Should be:
Code:
  if(item_amount($item[cherry]) == 0)
   buy(6 - item_amount($item[cherry]), $item[cherry]);
  if(item_amount($item[boxed wine]) == 0)
   buy(3 - item_amount($item[boxed wine]), $item[boxed wine]);

Simply remove one set of () from each buy line. Then () around the 3-item_amount... and 6-item_amount....

Another thing... Why buy 6 cherry's and 3 boxed wine? Is this supposed to loop until you have consumed enough sangria?

Personally I would do:
Code:
void drinkTPS(){
	if(item_amount($item[sangria del diablo]) == 0){
		if(item_amount($item[cherry]) == 0) buy(6 - item_amount($item[cherry]), $item[cherry]);
		if(item_amount($item[boxed wine]) == 0) buy(3 - item_amount($item[boxed wine]), $item[boxed wine]);
		if(item_amount($item[sangria]) == 0) create(1, $item[sangria]);
		create(1, $item[sangria del diablo]);
	}
	drink(1, $item[sangria del diablo]);
}
 

Sako

Member
That is not the problem, the script runs fine, the problem only occurs when there is a connection timeout.
 
Top