Guest User

Untitled

a guest
Apr 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. function fvSellBushels()
  2. {
  3. AddLog2('fvCrafter: Sharing Bushels');
  4. $opens = array();
  5. //Create list of bushels to buy
  6. $bsettings = $this->fvGetSettings2('b', true);
  7. $bbushels = array();
  8. //Get Bushels For Crops
  9. $object = GetObjects('Plot');
  10. $eobject = GetObjects('Plot', 'england');
  11. $fobject = GetObjects('Plot', 'fisherman');
  12. $wobject = GetObjects('Plot', 'winterwonderland');
  13. $objects = array_merge($object, $eobject, $fobject, $wobject);
  14. foreach ($objects as $object)
  15. {
  16. if ($object['itemName'] != 'plowed') {
  17. $uInfo = $this->units[$object['itemName']];
  18. if (!isset($bsettings[$uInfo['bushelItemCode']])) $bsettings[$uInfo['bushelItemCode']] = $this->settings['cropsave'];
  19. }
  20. }
  21. $csettings = $this->fvGetSettings2('c', true);
  22. foreach ($csettings as $setting)
  23. {
  24. $craftinfo = Crafts_GetByCode($setting['settings2_code']);
  25. $ingredients = explode(':', $craftinfo['Ingredient_itemCode']);
  26. foreach ($ingredients as $ingred)
  27. {
  28. if(!isset($this->settings['bmanager']) || $this->settings['bmanager'] == 0) @$bsettings[$ingred] = $this->settings['craftsave'];
  29. }
  30.  
  31. }
  32. foreach ($this->binvent as $bushel=>$amount)
  33. {
  34. if (!isset($bsettings[$bushel]))
  35. {
  36. $uInfo = Units_GetUnitByCode($bushel);
  37. $opens[$uInfo['name']]['items'][] = $uInfo;
  38. $opens[$uInfo['name']]['cnt'] = $amount;
  39. } elseif ($amount > $bsettings[$bushel]) {
  40. $uInfo = Units_GetUnitByCode($bushel);
  41. $opens[$uInfo['name']]['items'][] = $uInfo;
  42. $opens[$uInfo['name']]['cnt'] = $amount - $bsettings[$bushel];
  43. }
  44. }
  45.  
  46. if (empty($opens)) return;
  47. $amfcnt = 0;
  48. $amf = '';
  49. foreach ($opens as $key=>$open)
  50. {
  51. if ($open['cnt'] == 0) continue;
  52. $output = 'fvCrafter: Sharing - ' . Units_GetRealnameByName($key) . ' - ' . $open['cnt'] . ' - ';
  53. foreach ($open['items'] as $item)
  54. {
  55. $amf = CreateMultAMFRequest($amf, $amfcnt, '', 'CraftingService.onShareBushels');
  56. $amf->_bodys[0]->_value[1][$amfcnt]['params'][0] = $item['code'];
  57. $amf->_bodys[0]->_value[1][$amfcnt]['params'][1] = $open['cnt'];
  58. $amfcnt++;
  59. if ($amfcnt == $_SESSION['bot_speed']) {
  60. $res = RequestAMF($amf);
  61. $amf = '';
  62. $amfcnt = 0;
  63. if ($res != 'OK') {
  64. AddLog2('fvCrafter: Error - ' . $res);
  65. DoInit();
  66. }
  67. }
  68. }
  69. if (!empty($amf))
  70. {
  71. //AddLog2(print_r($amf,true));
  72. $res = RequestAMF($amf);
  73. $amf = '';
  74. $amfcnt = 0;
  75. if ($res != 'OK') {
  76. AddLog2('fvCrafter: Error - ' . $res);
  77. DoInit();
  78. }
  79. }
  80. AddLog2($output . $res);
  81. }
  82. }
Add Comment
Please, Sign In to add comment