Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fvSellBushels()
- {
- AddLog2('fvCrafter: Sharing Bushels');
- $opens = array();
- //Create list of bushels to buy
- $bsettings = $this->fvGetSettings2('b', true);
- $bbushels = array();
- //Get Bushels For Crops
- $object = GetObjects('Plot');
- $eobject = GetObjects('Plot', 'england');
- $fobject = GetObjects('Plot', 'fisherman');
- $wobject = GetObjects('Plot', 'winterwonderland');
- $objects = array_merge($object, $eobject, $fobject, $wobject);
- foreach ($objects as $object)
- {
- if ($object['itemName'] != 'plowed') {
- $uInfo = $this->units[$object['itemName']];
- if (!isset($bsettings[$uInfo['bushelItemCode']])) $bsettings[$uInfo['bushelItemCode']] = $this->settings['cropsave'];
- }
- }
- $csettings = $this->fvGetSettings2('c', true);
- foreach ($csettings as $setting)
- {
- $craftinfo = Crafts_GetByCode($setting['settings2_code']);
- $ingredients = explode(':', $craftinfo['Ingredient_itemCode']);
- foreach ($ingredients as $ingred)
- {
- if(!isset($this->settings['bmanager']) || $this->settings['bmanager'] == 0) @$bsettings[$ingred] = $this->settings['craftsave'];
- }
- }
- foreach ($this->binvent as $bushel=>$amount)
- {
- if (!isset($bsettings[$bushel]))
- {
- $uInfo = Units_GetUnitByCode($bushel);
- $opens[$uInfo['name']]['items'][] = $uInfo;
- $opens[$uInfo['name']]['cnt'] = $amount;
- } elseif ($amount > $bsettings[$bushel]) {
- $uInfo = Units_GetUnitByCode($bushel);
- $opens[$uInfo['name']]['items'][] = $uInfo;
- $opens[$uInfo['name']]['cnt'] = $amount - $bsettings[$bushel];
- }
- }
- if (empty($opens)) return;
- $amfcnt = 0;
- $amf = '';
- foreach ($opens as $key=>$open)
- {
- if ($open['cnt'] == 0) continue;
- $output = 'fvCrafter: Sharing - ' . Units_GetRealnameByName($key) . ' - ' . $open['cnt'] . ' - ';
- foreach ($open['items'] as $item)
- {
- $amf = CreateMultAMFRequest($amf, $amfcnt, '', 'CraftingService.onShareBushels');
- $amf->_bodys[0]->_value[1][$amfcnt]['params'][0] = $item['code'];
- $amf->_bodys[0]->_value[1][$amfcnt]['params'][1] = $open['cnt'];
- $amfcnt++;
- if ($amfcnt == $_SESSION['bot_speed']) {
- $res = RequestAMF($amf);
- $amf = '';
- $amfcnt = 0;
- if ($res != 'OK') {
- AddLog2('fvCrafter: Error - ' . $res);
- DoInit();
- }
- }
- }
- if (!empty($amf))
- {
- //AddLog2(print_r($amf,true));
- $res = RequestAMF($amf);
- $amf = '';
- $amfcnt = 0;
- if ($res != 'OK') {
- AddLog2('fvCrafter: Error - ' . $res);
- DoInit();
- }
- }
- AddLog2($output . $res);
- }
- }
Add Comment
Please, Sign In to add comment