function Do_Work() { global $settings; global $need_reload; global $px_Setops; global $res_str; pluginload(); $vDir = './farmville-logs'; if (!file_exists($vDir)) { mkdir($vDir); } $time_limit = 7 * 24 * 60 * 60; // number of seconds to 'keep' the log DAYSxHOURSxMINSxSECS if ($df = opendir($vDir)) { while (false !== ($file = readdir($df))) { if ($file != "." && $file != "..") { $file1 = $vDir . '/' . $file; $last_modified = filemtime($file1); if (time() - $last_modified > $time_limit) { unlink($file1); } } } closedir($df); } while (file_exists('notrun_parser.txt') || file_exists('notrun_parser_' . $_SESSION['userId'] . '.txt')) { AddLog2("Bot Paused. Next check in 30 seconds."); sleep(30); } parse_neighbors(); parse_user(); AddLog2("Beginning Bot Cycle"); Hook('before_work'); // Init $res = DoInit('full'); if ($res != 'OK') { RaiseError(2); } else { $res_str = ''; //for main logs } Hook('before_load_settings'); // load settings if (!function_exists('LoadSavedSettings')) { die("\n\nSettings plugin installed incorrectly no LoadSavedSettings found!\n\n"); } $px_Setopts = LoadSavedSettings(); $enable_lonlyanimals = $px_Setopts['lonlyanimals']; Hook('after_load_settings'); if ($enable_lonlyanimals) { AddLog2("check lonlyanimal"); Do_Check_Lonlyanimals(); } Hook('flybiplane'); Hook('before_harvest'); Hook('harvest'); Hook('after_harvest'); Hook('before_harvest_buildings'); Hook('harvest_buildings'); Hook('after_harvest_buildings'); //after building harvest Hook('before_harvest_animals'); //get product from livestock Hook('harvest_animals'); Hook('after_harvest_animals'); Hook('before_transform_animals'); Hook('transform_animals'); Hook('after_transform_animals'); Hook('before_harvest_trees'); Hook('harvest_trees'); Hook('after_harvest_trees'); Hook('before_hoe'); Hook('hoe'); Hook('after_hoe'); Hook('before_before_planting'); Hook('before_planting'); Hook('planting'); Hook('after_planting'); Hook('after_work'); Parser_Check_Images(); AddLog2("Peak Memory Usaged: " . round(memory_get_peak_usage(true) / 1024 / 1024, 2) . "MB"); AddLog2("Finished Bot Cycle"); }
function Do_Farm_Work_Plots($plots, $action = "harvest") { global $vCnt63000; list(, , , , , , , , , , $fuel) = explode(';', fBGetDataStore('playerinfo')); if (@strlen($vCnt63000) == 0) { $vCnt63000 = 63000; } $px_Setopts = LoadSavedSettings(); if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] < 1) { $px_Setopts['bot_speed'] = 1; } if (@$px_Setopts['bot_speed'] > PARSER_MAX_SPEED) { $px_Setopts['bot_speed'] = PARSER_MAX_SPEED; } $vMaxEquip = 16; if (@(!$fuel) || @$fuel < 0) { $fuel = 0; } if ($fuel == 0 && $action == 'tractor') { return; } if ($fuel == 0) { Do_Farm_Work($plots, $action); return; } while (count($plots) > 0) { $amf = new AMFObject(""); $amf->_bodys[0] = new MessageBody(); $amf->_bodys[0]->targetURI = 'FlashService.dispatchBatch'; $amf->_bodys[0]->responseURI = '/1/onStatus'; $amf->_bodys[0]->responseIndex = '/1'; $amf->_bodys[0]->_value[0] = GetAMFHeaders(); $amf->_bodys[0]->_value[2] = 0; $vCntSpeed = 0; while (count($plots) > 0 && $vCntSpeed < $px_Setopts['bot_speed'] && $fuel > 0) { $amf->_bodys[0]->_value[1][$vCntSpeed]['sequence'] = GetSequense(); $amf->_bodys[0]->_value[1][$vCntSpeed]['functionName'] = "EquipmentWorldService.onUseEquipment"; if ($action == 'tractor') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = 'plow'; } else { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][0] = $action; } $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['id'] = -1; if ($action == 'harvest') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'V1:32'; } # fully expanded harvester if ($action == 'tractor' || $action == 'plow') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'T1:32'; } # fully expanded tractor if ($action == 'place') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][1]['key'] = 'S1:32'; } # fully expanded seeder $vCntEquip = 0; $vSeed = ''; $vLastSeed = ''; while (count($plots) > 0 && $vCntEquip < $vMaxEquip && $fuel > 0) { $vPlot = array_pop($plots); if ($action == 'place') { $vSeed = $vPlot['itemName']; if ($vLastSeed == '') { $vLastSeed = $vSeed; } elseif ($vLastSeed != $vSeed) { array_push($plots, $vPlot); break; } } if (@(!$plotsstring)) { $plotsstring = $vPlot['itemName'] . " " . GetPlotName($vPlot); } else { $plotsstring = $plotsstring . ", " . $vPlot['itemName'] . " " . GetPlotName($vPlot); } if (@(!$OKstring)) { $OKstring = $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot); } else { $OKstring = $OKstring . "\r\n" . $action . " " . $vPlot['itemName'] . " on plot " . GetPlotName($vPlot); } $fuel--; if ($action == 'tractor') { $vCnt63000++; $vPlot['id'] = $vCnt63000; $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip] = $vPlot; } else { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][2][$vCntEquip]['id'] = $vPlot['id']; } $vCntEquip++; } if ($action == 'tractor' || $action == 'harvest' || $action == 'plow') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = 'plowed'; } if ($action == 'place') { $amf->_bodys[0]->_value[1][$vCntSpeed]['params'][3] = $vSeed; } $vCntSpeed++; } AddLog2($action . " " . $plotsstring); $res = RequestAMF($amf); AddLog2("result {$res}"); unset($amf->_bodys[0]->_value[1]); if ($res === 'OK') { AddLog($OKstring); $need_reload = true; } else { if ($res) { AddLog("Error: {$res} on " . $OKstring); if (intval($res) == 29 || strpos($res, 'BAD AMF') !== false) { // Server sequence was reset DoInit(); } } } unset($plotsstring, $OKstring); } $px_Setopts = LoadSavedSettings(); if ($action == 'plow' || $action == 'tractor') { $px_Setopts['fuel_plow'] = $fuel; } if ($action == 'place') { $px_Setopts['fuel_place'] = $fuel; } if ($action == 'harvest') { $px_Setopts['fuel_harvest'] = $fuel; } SaveSettings($px_Setopts); }
private function _fvAMFSend($amf) { $serializer = new AMFSerializer(); $result3 = $serializer->serialize($amf); // serialize the data $answer = Request('', $result3); $amf2 = new AMFObject($answer); $deserializer2 = new AMFDeserializer($amf2->rawData); // deserialize the data $deserializer2->deserialize($amf2); // run the deserializer $doinit = 0; if (!isset($amf2->_bodys[0]->_value['data'][0])) { DoInit(); return false; } Check4Rewards($amf2); foreach (@$amf2->_bodys[0]->_value['data'] as $key => $returned) { $resp = $returned['errorType']; $err = $returned['errorData']; if ($resp == 28 || $resp == 29) { if (strpos($err, 'MC::lock()') !== false) { //Ignore Quietly Now, even if Debug is on $iguser = load_array('ignores.txt'); preg_match('/rts_USER_(.*)_lock/', $err, $matches); $iguser[floatval($matches[1])] = floatval($matches[1]); save_array($iguser, 'ignores.txt'); } else { if ($this->settings['debug'] == 1 && $err != 'Remaining function') { AddLog2('fvManager Error: ' . $resp . ' - ' . $err); } } unset($amf2->_bodys[0]->_value['data'][$key]); if ($doinit == 0) { DoInit(); } $doinit = 1; if ($key == 0) { return false; } } } return $amf2; }
function FarmStats_Refresh() { DoInit(); $fvM = new FarmStats(); unset($fvM); }
function Giftbox() { AddLog2('GiftBox: Start'); $T = time(true); // begin SQL setup $this->GBDBuser_init("Hook"); $this->GB_renew_giftbox_SQL(); // end SQL setup // Get the settings $GBSQL = "SELECT _val,_set FROM gamesettings"; $result = $this->_GBUser->query($GBSQL); if ($result->numRows() > 0) { $GB_results = $result->fetchAll(); foreach ($GB_results as $GB_result) { $this->GB_Setting[$GB_result['_set']] = $GB_result['_val']; } } // import default actions? $this->GB_AutoActionFile(); // if place is on, than let's update the locations to find empty locations if ($this->GB_Setting['DoPlace']) { $this->GBCreateMap(); } AddLog2('GiftBox: Detecting Building Parts'); $this->GB_DetectBuildingParts4(); $this->GB_BuildingParts4(); if ($this->GB_Setting['RunPlugin']) { //check the cellar for storage. if ($this->GB_Setting['DoStorage']) { $this->GB_checkCellar(); } // check this amount of items in giftbox. $result1 = $this->_GBUser->query("SELECT SUM(_amount) FROM giftbox"); if ($result1->numRows() > 0) { $GB_total_in_giftbox = $result1->fetchSingle(); } else { $GB_total_in_giftbox = 0; } AddLog2("GiftBox: Items Counted - " . $GB_total_in_giftbox); global $GB_tempid; if ($GB_tempid == "") { $GB_tempid = 63000; } //get the collection info. $GBccount = array(); $GBccount = GB_LoadCcount(); $GB_changed = false; //true when we did action. $MAP_ObjectArray = array(); $Map_all_items = array(); $MapXY = array(); $EmptyXY = array(); if ($this->GB_Setting['DoFeetPet']) { AddLog2("GiftBox: Detecting Pet(s)"); $GB_Pets = $this->GB_FindPetsSQL(); $found = count(array_keys($GB_Pets)); AddLog2("GiftBox: Found {$found} Pet(s)"); if ($found > 0) { foreach ($GB_Pets as $GB_Petfeed) { if ($GB_Petfeed['isRunAway'] == 1) { AddLog2('GiftBox: ' . $GB_Petfeed['petName'] . ' Has Ran Away'); } else { $FeedWhat = $GB_Petfeed['FeedWhat']; $FeedName = $GB_Petfeed['petName']; AddLog2('GiftBox: ' . $FeedName . ' Needs: ' . $FeedWhat . ' ' . nicetime($GB_Petfeed['feedtime'])); } } } } // DoFeetPet // load the totstorage. $GBSQL = "SELECT * FROM totstorage "; $query = $this->_GBUser->query($GBSQL); $totstorages = $query->fetchAll(); if (!is_array($totstorages)) { $totstorages = array(); } // load the giftbox... $GBSQL = "SELECT * FROM giftbox "; $query = $this->_GBUser->query($GBSQL); $giftboxs = $query->fetchAll(); foreach ($giftboxs as $giftbox) { $GB_ItemCode = $giftbox["_itemcode"]; $GB_ItemAmount = $giftbox["_amount"]; // if items = 0 then skip this item. if ($GB_ItemAmount < 1) { continue; } $place_on_farm = ''; $place_in_build = ''; $place_in_amount = ''; $place_in_max = ''; $place_in_special = ''; $target = ''; $selling = ''; $keep = 0; $construction = ''; $collection = ''; $consume = ''; // Let's check if there is action for this item. $GBSQL = "SELECT * FROM action WHERE _code = '" . $GB_ItemCode . "'"; $query = $this->_GBUser->query($GBSQL); $action = $query->fetchAll(); if (!empty($action)) { // so there is action. $place_on_farm = $action['0']['_place_on_farm']; $place_in_build = $action['0']['_place_in_build']; $place_in_amount = $action['0']['_place_in_amount']; $place_in_max = $action['0']['_place_in_max']; $place_in_special = $action['0']['_place_in_special']; $target = $action['0']['_target']; $selling = $action['0']['_selling']; $construction = $action['0']['_construction']; $keep = $action['0']['_keep']; $collection = $action['0']['_collection']; $consume = $action['0']['_consume']; } // prepare Unit settings $GBSQL = "SELECT * FROM units WHERE _code = '" . $GB_ItemCode . "' "; $query = $this->_GBMain->query($GBSQL); $Unit = $query->fetchAll(); // Get the realname $Unit['0']['realname'] = $this->GB_get_friendlyName($Unit['0']['_name']); // check if we need to feed pet $FeedNowCheck = false; $PetFeedFound = ""; if ($GB_ItemCode == "0O") { $FeedNowCheck = true; $PetFeedFound = "Puppy Kibble "; } if ($GB_ItemCode == "0z") { $FeedNowCheck = true; $PetFeedFound = "Dog Treat "; } if ($FeedNowCheck == true && $this->GB_Setting['DoFeetPet']) { AddLog('GiftBox: ' . $GB_ItemAmount . " " . $PetFeedFound . " Found - Checking If Needed"); if ($GB_ItemAmount > 0) { // loop all pets foreach ($GB_Pets as $GB_Petfeed) { if ($GB_Petfeed['isRunAway'] == 1) { AddLog2('GiftBox: ' . $GB_Petfeed['petName'] . ' Has Ran Away - Cannot Feed'); } else { $FeedWhat = $GB_Petfeed['FeedWhat']; $FeedName = $GB_Petfeed['petName']; $FeedNow = true; if ($FeedWhat == "kibble" && $GB_ItemCode == "0z") { AddLog2("GiftBox: This Puppy Does Not Need Dog Treats.."); $FeedNow = false; } if ($FeedWhat == "treat" && $GB_ItemCode == "0O") { AddLog2("GiftBox: This Dog Does Not Need Kibble.."); $FeedNow = false; } if ($FeedNow == true) { $UnixNow = time(); if ($UnixNow > $GB_Petfeed['feedtime']) { // need feed now $FeedWhat = $GB_Petfeed['FeedWhat']; $result = GB_consumePet($GB_Petfeed['id'], "consume_" . $FeedWhat); AddLog2("GiftBox: Feeding " . $GB_Petfeed['petName'] . " " . $FeedWhat . '- ' . $result); if ($result == "OK") { AddLog2("GiftBox: Kibble Has Been Fed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, "Pet feed", $GB_ItemAmount, "Pet Feed"); //GB_Stat($GB_ItemCode, "Kibble feed", 0, 0, $GB_ItemAmount,0 ); } else { $giftboxs = array(); break; } } else { AddLog2($GB_Petfeed['petName'] . ' Needs to be Fed ' . nicetime($GB_Petfeed['feedtime'])); } } } } } } // End pet feet. // check target settings global. if ($target != 0) { $Target = $this->GBSQLGetObjByID($target); $TotItems = 0; $TargetItemHave = 0; // map the content of the target and find the total items have if (is_array($Target['contents'])) { // count the contents foreach ($Target['contents'] as $content) { $TotItems = $TotItems + $content['numItem']; $TargetCont[$content['itemCode']] = $content['numItem']; if ($GB_ItemCode == $content['itemCode']) { $TargetItemHave = $content['numItem']; } } } // end contents // now check if the item is in totstorage. $featureCreditsName = 'N'; if ($Target['itemName'] == 'valentinesbox') { $featureCreditsName = 'valentine'; } if ($Target['itemName'] == 'potofgold') { $featureCreditsName = 'potOfGold'; } if ($Target['itemName'] == 'easterbasket') { $featureCreditsName = 'easterBasket'; } if ($Target['itemName'] == 'wedding') { $featureCreditsName = 'tuscanWedding'; } if ($Target['itemName'] == 'beehive_finished') { $featureCreditsName = 'beehive'; } if ($Target['itemName'] == 'hatchstorage') { $featureCreditsName = 'InventoryCellar'; } //added if ($featureCreditsName != 'N') { $GBSQL = "SELECT * FROM totstorage WHERE _storagecode = '" . $featureCreditsName . "' AND _itemcode = 'current'"; $query = $this->_GBUser->query($GBSQL); if ($query->numRows() > 0) { $totstorage = $query->fetchAll(); $TotItems = $totstorages['0']['_amount']; } } // Get target unit details. $GBSQL = "SELECT * FROM units WHERE _name = '" . $Target['itemName'] . "' "; $result = $this->_GBMain->query($GBSQL); $TargetUnit = $result->fetchAll(); // check capacity of target $TargetCapacity = 0; if (!array_key_exists('isFullyBuilt', $Target)) { $Target['isFullyBuilt'] = "N"; } if ($Target['isFullyBuilt'] == "1") { $TargetCapacity = $TargetUnit['0']['_capacity']; if (array_key_exists('expansionLevel', $Target)) { $level = $Target['expansionLevel']; if ($level > 1) { $GBSQL = "SELECT _capacity FROM unitbuilding WHERE _level = '" . $level . "' AND _buildingcode = '" . $TargetUnit['0']['_code'] . "' "; $result = $this->_GBMain->query($GBSQL); $TargetCapacity = $result->fetchSingle(); } } else { $level = 0; } } // end fully build // check if building is in construction $TargetIsConstruction = 'N'; if ($Target['state'] == 'construction') { $TargetIsConstruction = 'Y'; } else { // check if it is a horsestable if ($Target['itemName'] == 'horsestablewhite') { // check if horse stable has expansionParts if (count(array_keys($Target['expansionParts'])) > 0) { // yes, we have expansionParts $TargetIsConstruction = 'Y'; } if ($TargetItemHave > 0) { // yes, we have expansionParts $TargetIsConstruction = 'Y'; } } } } // End check target //check if we can store this item. if ($this->GB_Setting['DoStorage']) { $Able2Store = GB_CanWeStore($Unit['0']); if ($this->GB_Setting['StorageLocation'] == 'N') { $Able2Store = 'N'; } else { if ($this->GB_Setting['StorageUsed'] >= $this->GB_Setting['StorageCapacity']) { // storage is full. $Able2Store = 'N'; AddLog2("GiftBox: Storage is Full?"); } } if ($this->GB_Setting['DoStorage'] && $Able2Store == 'Y' && $GB_ItemAmount > 0) { // check content of storage AddLog2("GiftBox: Entering Storage Routine For: " . $Unit['0']['realname']); $cellars = unserialize($this->GB_Setting['StorageContent2']); $AmountInCellar = 0; if (array_key_exists($GB_ItemCode, $cellars)) { $AmountInCellar = $cellars[$GB_ItemCode]; } AddLog2("GiftBox: Store " . $GB_ItemAmount . " " . $Unit['0']['realname'] . '?'); if ($this->GB_Setting['DoStorage1'] && $AmountInCellar < 1) { $Amount2Store = 1; AddLog2("GiftBox: Store " . $Amount2Store . " " . $Unit['0']['realname']); } else { AddLog2("GiftBox: Store " . $Unit['0']['realname'] . " Already in Storage"); } if ($Amount2Store > 0) { $result = GB_StoreCel($Unit['0'], $Amount2Store); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Added"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Fuel added"); $GB_ItemAmount = $GB_ItemAmount - $Amount2Store; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: No Need to Store This Item."); } } // end stor } // check if we can use the item to store into a building if ($place_in_build != 0 && $target != 0 && $this->GB_Setting['DoPlaceBuild'] && $GB_ItemAmount > 0) { //$place_in_max AddLog2('GiftBox ' . $Target['itemName'] . ' - Capacity: ' . $TargetCapacity . ' - Have: ' . $TotItems); $finished = false; if ($TotItems >= $TargetCapacity) { // The building is full lets skip this item. AddLog2("GiftBox: This Building is Full - Skipping"); $finished = true; } while (!$finished) { $result = GB_storeItem($Unit['0'], $Target); if ($result == "OK") { $GB_changed = true; //update the amount. AddLog2('GiftBox: Placed in Building ' . $Unit['0']['_name'] . ' - Total in Building: ' . $TotItems); $this->GB_SQL_updAction("_place_in_build", $GB_ItemCode, $place_in_build - $GB_ItemAmount); //$field, $code, $val //update stats. $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Into building"); $TotItems++; $GB_ItemAmount--; } else { $finished = true; $giftboxs = array(); break; } if ($TotItems >= $TargetCapacity) { $finished = true; } if ($GB_ItemAmount < 1) { $finished = true; } } // not full } //end place in build // check if we have to place construction in a building // construction = # or Y 0 = not construction if ($construction == 'Y' && $this->GB_Setting['DoConstr'] && $GB_ItemAmount > 0) { $go = $GB_ItemAmount; $used = 0; while ($go > 0) { AddLog2('GiftBox: Construction Part ' . $Unit['0']['_name'] . ' Found ' . $go); $GBSQL = "SELECT * FROM BuildingParts WHERE _itemCode = " . $this->Qs($GB_ItemCode) . " AND _action ='construction' AND _ObjHave < 10 LIMIT " . $go; $query = $this->_GBUser->query($GBSQL); if ($query->numRows() > 0) { $BuildingParts = $query->fetchAll(); foreach ($BuildingParts as $BuildingPart) { // 1 or more targets found $Target = $this->GBSQLGetObjByID($BuildingPart['_ObjId']); AddLog2('GiftBox: Part: ' . $BuildingPart['_itemName'] . ' For ' . $BuildingPart['_UnitBuildName'] . " - Contains: " . $BuildingPart['_ObjHave'] . " - Adding 1"); $result = GB_storeItem($Unit['0'], $Target); if ($result == "OK") { $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Construction"); //update the amount have $have = $BuildingPart['_ObjHave'] + 1; $GBSQL = "UPDATE BuildingParts SET _ObjHave=" . $this->Qs($have) . " WHERE _UnitBuildName = " . $this->Qs($BuildingPart['_UnitBuildName']) . " AND _itemCode = " . $this->Qs($GB_ItemCode); $query = $this->_GBUser->query($GBSQL); $go--; $used++; } else { $go = 0; $giftboxs = array(); break; } } } else { //skip there are no target buildings AddLog2('GiftBox: Construction Part Not Needed. (' . $GB_ItemCode . ')'); $go = 0; } } // while $GB_ItemAmount > 1 $GB_ItemAmount = $GB_ItemAmount - $used; } // constructions // check if we have Special to handle if ($place_in_special != 0 && $target != 0 && $this->GB_Setting['DoSpecials'] && $GB_ItemAmount > 0) { AddLog2('GiftBox: Special ' . $TargetUnit['0']['_name'] . " For " . $Target['itemName']); // for specials there is no max. $result = GB_storeItem2($Unit['0'], $Target, $GB_ItemAmount); if ($result == "OK") { //GB_SpecialThisUpdate($GB_ItemCode, $GB_ItemAmount); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Special"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } // check if we have collection if ($collection == 'Y' && $this->GB_Setting['DoColl'] && $GB_ItemAmount > 0) { $Amount_in_Collection = GB_GetColInfo($GB_ItemCode, $GBccount); // Check if we have less than 10 if ($Amount_in_Collection < 10 && $GB_ItemAmount > 0) { if ($Amount_in_Collection + $GB_ItemAmount <= 10) { $Amount_to_add = $GB_ItemAmount; } else { $Amount_to_add = 10 - $Amount_in_Collection; } AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['_name'] . " - Have " . $Amount_in_Collection . " Will Add " . $Amount_to_add . " To Collection"); $result = GB_DoColAdd($Unit['0']['_name'], $GB_ItemCode, $Amount_to_add); if ($result == "OK") { AddLog2($Amount_to_add . " " . $Unit['0']['_name'] . " Added To Collection"); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Added collection"); $Amount_in_Collection = $Amount_in_Collection + $Amount_to_add; $GB_ItemAmount = $GB_ItemAmount - $Amount_to_add; } else { $giftboxs = array(); break; } } // end < 10 if ($Amount_in_Collection >= 10 && $GB_ItemAmount > 0) { //we have already 10 if ($this->GB_Setting['DoCollSell']) { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['_name'] . " - Have " . $Amount_in_Collection . " Will Sell Now"); $result = GB_DoSellCol($Unit['0'], $GB_ItemAmount); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Sold"); $GB_changed = true; $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Sold collection"); } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $ObjD['realname'] . " - Have " . $Amount_in_Collection . " Selling Disabled"); } // end do_sell } // end more 10. } // end collection // Place on farm if ($place_on_farm == 'Y' && $this->GB_Setting['DoPlace'] && $GB_ItemAmount > 0) { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Place on Farm"); $GB_Where = "Decoration"; if ($Unit['0']['_type'] == "animal") { $GB_Where = "Animal"; } if ($Unit['0']['_type'] == "tree") { $GB_Where = "Tree"; } //check if there is place on the farm. $GB_Free_place = $this->TEmptyXY3($GB_Where, "ALL"); if ($GB_Free_place < $GB_ItemAmount) { AddLog2("****** Error *****"); AddLog2("GiftBox: There is no room on you farm left."); AddLog2("GiftBox: To place: " . $GB_ItemAmount . " " . $Unit['0']['realname']); AddLog2("****** Error *****"); } else { $result = GB_PlaceM3($Unit['0'], $GB_ItemAmount, $GB_Where); if ($result == "OK") { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Placed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Placed"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } } // end place if ($Unit['0']['_type'] == 'fuel' && $this->GB_Setting['DoFuel'] && $GB_ItemAmount > 0) { // selling fuel enabled >> GB_BuyFuel($ObjD , $GB_amount) $result = GB_BuyFuel($Unit['0'], $GB_ItemAmount); AddLog2("GiftBox " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Fuel found - " . $result); if ($result == "OK") { AddLog2("GiftBox " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Added"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GB_ItemAmount, "Fuel added"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } // end fuel // consumable if ($consume == 'Y' && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_consume($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Consume - Leave in GiftBox: " . $keep . ' - ' . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: " . $GBAction_Amount . " " . $Unit['0']['realname'] . " Consumed"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Consume"); $GB_ItemAmount = 0; } else { DoInit(); $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in Giftbox: " . $keep); } } // end consumable // DoVehicle if ($this->GB_Setting['DoVehicle'] && $GB_ItemCode == "dS" && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; $vehicle = $this->GB_garage('hook'); $AmountOfRuns = $vehicle['0']['vehicle']; AddLog2("GiftBox: Have " . $GB_ItemAmount . " Vehicle Parts - " . $vehicle['0']['vehicle'] . " Vehicles Need Parts"); while ($AmountOfRuns >= 1 && $GBAction_Amount > 1) { $needpart = $vehicle[$AmountOfRuns]['need']; AddLog2("Giftbox: Vehicle " . $vehicle[$AmountOfRuns]['itemCode'] . " Needs " . $needpart . " Parts"); while ($needpart >= 1 && $GBAction_Amount > 1) { $result = GB_DoGarage($vehicle[$AmountOfRuns], $vehicle['0']['id']); if ($result == "OK") { $vehicle[$AmountOfRuns]['numParts'] = $vehicle[$AmountOfRuns]['numParts'] + 1; $needpart--; AddLog2("GiftBox: 1 " . $Unit['0']['realname'] . " Added, Need " . $needpart . ' More'); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Added"); $GBAction_Amount--; $GB_ItemAmount--; } else { $giftboxs = array(); break; } } $AmountOfRuns--; } } // end DoVehicle // check if we can open this. $GB_OpenArray = unserialize($this->GB_Setting['OpenItems']); if (in_array($GB_ItemCode, $GB_OpenArray)) { $GB_OpenThis = 'Y'; } else { $GB_OpenThis = 'N'; } if ($this->GB_Setting['DoMystery'] && $GB_ItemAmount > 0 && $GB_OpenThis == 'Y') { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_OpenGift($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: Open " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - " . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: Opened " . $GBAction_Amount . " " . $Unit['0']['realname'] . " - Done"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Opened"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in GiftBox: " . $keep); } } // end open if ($selling == 'Y' && $this->GB_Setting['DoSelling'] && $GB_ItemAmount > 0) { $GBAction_Amount = $GB_ItemAmount - $keep; if ($GBAction_Amount >= 1) { $result = GB_DoSellCol($Unit['0'], $GBAction_Amount); AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " Will be Sold - Leave in GiftBox: " . $keep . ' - ' . $result); $need_reload = true; if ($result == "OK") { AddLog2("GiftBox: " . $GBAction_Amount . " " . $Unit['0']['realname'] . " Sold"); $GB_changed = true; // giftbox changed $this->GB_Stat3($GB_ItemCode, $Unit['0']['_name'], $GBAction_Amount, "Sold"); $GB_ItemAmount = 0; } else { $giftboxs = array(); break; } } else { AddLog2("GiftBox: " . $GB_ItemAmount . " " . $Unit['0']['realname'] . " - Keep in GiftBox: " . $keep); } } // end Do_SellList } //end foreach giftbox // after giftbox, see the collection trade in. if ($this->GB_Setting['DoCollTrade']) { // now look to complete collections. AddLog2("Collection trade in set to: " . $this->GB_Setting['DoCollKeep']); $GB_CollCompete_res = GB_CollCompete(); // get the information while (list($GB_CollCode, $amount) = each($GB_CollCompete_res)) { AddLog2("Collection Info: [" . $GB_CollCode . "] has" . $amount . " completed"); $GB_Tradein_amount = $amount - $this->GB_Setting['DoCollKeep']; if ($GB_Tradein_amount > 0) { $GB_TradeIn_res = GB_TradeIn($GB_CollCode, $GB_Tradein_amount); AddLog2("Collection Trade In: [" . $GB_CollCode . "] " . $GB_Tradein_amount . " Time(s)"); $this->GB_Stat3($GB_CollCode, "Collection", $GB_Tradein_amount, "Trade in"); $GB_changed = true; } } } // end complete collection } else { AddLog2("Skipping GiftBox..."); } if ($GB_changed) { $res = $this->GB_renew_giftbox_SQL(); // update giftbox. so it shows correctly in the screen. } else { $T2 = time(); $T2 -= $T; AddLog2("Giftbox: Finished in " . $T2 . " Seconds"); } }
function TB_run_storagemanager($getFarm = null) { global $TB_settings; global $AM_settings; //######################################################################## // storagemanager functions //######################################################################## echo "StorageManager\r\n"; $farm = $getFarm; if (isset($TB_settings['SM_action']['sell']) || isset($TB_settings['SM_action']['place'])) { if (count($TB_settings['SM_action']['sell']) > 0) { SM_sell(); } if (count($TB_settings['SM_action']['place']) > 0) { if (!isset($farm)) { AddLog2('TB - reloding farm'); DoInit(); $farm = TB_buildFarmArray(); } $re = SM_place($farm); if (is_array($re)) { $farm = $re; } } $TB_settings['TB_needReload'] = true; } return $farm; }
function Sections_plant_sections() { global $need_reload; $enable_seed = true; echo "Sections v", sections_Version, " >> plant_sections\r\n"; $sections = load_array('sections.txt'); if (!(is_array($sections) && count($sections))) { return; } #return; // uncomment to disable for debug purposes if ($need_reload) { $res = DoInit(); //reload farm $need_reload = false; } # $units = @unserialize(file_get_contents(F('units.txt'))); $objects = @unserialize(fBGetDataStore('objects')); list($level, $gold, $cash, $sizeX, $sizeY, $firstname, $locale, $tileset, $wither, $xp, $energy, $flashRevision) = explode(';', fBGetDataStore('playerinfo')); // Build matrix so we can know which locations are empty $location_empty = array(); for ($x = 0; $x < $sizeX; $x++) { for ($y = 0; $y < $sizeY; $y++) { $location_empty[$x][$y] = true; } } foreach ($objects as $o) { # $u = $units[$o['itemName']]; $u = Units_GetUnitByName($o['itemName']); if (!isset($u['sizeX'])) { $u['sizeX'] = 1; $u['sizeY'] = 1; } if ($o['state'] == 'vertical') { $t = $u['sizeX']; $u['sizeX'] = $u['sizeY']; $u['sizeY'] = $t; } for ($x = 0; $x < $u['sizeX']; $x++) { for ($y = 0; $y < $u['sizeY']; $y++) { $location_empty[$o['position']['x'] + $x][$o['position']['y'] + $y] = false; } } } foreach ($sections as $section) { if ($section['active'] == '1' && $section['place'] == '1' && $section['type'] == 'seed') { $u['sizeX'] = 4; $u['sizeY'] = 4; while ($newpos = Sections_Find_Free_Location_Buy($section, $u, $location_empty)) { unset($vPlot); $vPlot['itemName'] = null; $vPlot['isProduceItem'] = false; $vPlot['isBigPlot'] = false; $vPlot['direction'] = 0; $vPlot['plantTime'] = 'NaN'; $vPlot['deleted'] = false; $vPlot['isJumbo'] = false; $vPlot['state'] = 'plowed'; $vPlot['tempId'] = -1; $vPlot['id'] = 0; $vPlot['className'] = 'Plot'; $vPlot['position']['z'] = 0; $vPlot['position']['x'] = (int) $newpos['x']; $vPlot['position']['y'] = (int) $newpos['y']; $tractor_plots[] = $vPlot; for ($x = 0; $x < $u['sizeX']; $x++) { for ($y = 0; $y < $u['sizeY']; $y++) { $location_empty[$newpos['x'] + $x][$newpos['y'] + $y] = false; } } } } } if (isset($tractor_plots) && count($tractor_plots) > 0) { $result = Do_Farm_Work_Plots($tractor_plots, 'tractor'); $need_reload = $need_reload || $result; } // Below mostly copied from parser.php with adaptions if ($need_reload) { $res = DoInit(); //reload farm $need_reload = false; } if ($enable_seed) { $plots = GetObjects('Plot'); //Find empty plots $plowed_plots = array(); foreach ($plots as $plowed_key => $plot) { if ($plot['state'] == 'plowed') { $plowed_plots[] = $plot; } } $seed_plots = array(); foreach ($plowed_plots as $plot) { $itemName = ""; $px = floor($plot['position']['x'] / 4); $py = floor($plot['position']['y'] / 4); $npx = $plot['position']['x']; $npy = $plot['position']['y']; foreach ($sections as $section) { if ($section['active'] == '1' && $section['type'] == 'seed' && $section['seed'] != 'just_plow' && $section['seed'] != '---' && $npx >= $section['bot_x'] && $npx <= $section['top_x'] && $npy >= $section['bot_y'] && $npy <= $section['top_y']) { // found the section switch ($section['pat']) { case 'checkerboard': $itemName = ($px + $py) % 2 == 1 ? $section['seed'] : $section['seed2']; break; case 'striped-row': $itemName = $py % 2 == 1 ? $section['seed'] : $section['seed2']; break; case 'striped-col': $itemName = $px % 2 == 1 ? $section['seed'] : $section['seed2']; break; case 'squared1': $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2']; break; case 'squared2': $itemName = $px % 2 == 1 || $py % 2 == 1 ? $section['seed'] : $section['seed2']; break; case 'corner-w': $itemName = $px % 2 == 1 && $px >= $py || $py % 2 == 1 && $py >= $px ? $section['seed'] : $section['seed2']; break; case 'corner-e': $itemName = $px % 2 == 1 && $px <= $py || $py % 2 == 1 && $py <= $px ? $section['seed'] : $section['seed2']; break; case 'corner-n': $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4); $itemName = $px % 2 == 1 && $sz_x - $px <= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2']; break; case 'corner-s': $sz_x = floor(($section['top_x'] - $section['bot_x']) / 4); $itemName = $px % 2 == 1 && $sz_x - $px >= $py || $py % 2 == 1 && $py <= $sz_x - $px ? $section['seed'] : $section['seed2']; break; default: $itemName = $section['seed']; } } } if (strlen($itemName) > 0) { $plot['itemName'] = $itemName; $seed_plots[] = $plot; # } else { # echo GetPlotName($plot) . " not in a section."; } } if (count($seed_plots) > 0) { Do_Farm_Work_Plots($seed_plots, 'place'); //plant crops } unset($seed_plots, $plowed_plots); } }
function RequestAMF2($amf) { $serializer = new AMFSerializer(); $result = $serializer->serialize($amf); // serialize the data $answer = Request('', $result); $amf2 = new AMFObject($answer); $deserializer2 = new AMFDeserializer($amf2->rawData); // deserialize the data $deserializer2->deserialize($amf2); // run the deserializer Check4Rewards($amf2); // Check if there was a error // Check if there was data[0] and or data[1] $errorfound = 'N'; $errorType = ''; $errorData = ''; if (@$amf2->_bodys[0]->_value['errorType'] != 0) { $errorfound = 'Y'; $errorType = $amf2->_bodys[0]->_value['errorType']; $errorData = $amf2->_bodys[0]->_value['errorData']; } if (isset($amf2->_bodys[0]->_value['data'][0])) { if (@$amf2->_bodys[0]->_value['data'][0]['errorType'] != 0) { $errorfound = 'Y'; $errorType = $amf2->_bodys[0]->_value['data'][0]['errorType']; $errorData = $amf2->_bodys[0]->_value['data'][0]['errorData']; } } if (isset($amf2->_bodys[0]->_value['data'][1])) { if (@$amf2->_bodys[0]->_value['data'][1]['errorType'] != 0) { $errorfound = 'Y'; $errorType = $amf2->_bodys[0]->_value['data'][1]['errorType']; $errorData = $amf2->_bodys[0]->_value['data'][1]['errorData']; } } if ($errorfound == 'Y') { if ($errorData == "There is a new version of the farm game released") { AddLog2('FV UPDATE: New Version of FV Released'); AddLog2('Work Will Restart in 15 Seconds'); unlink('unit_check.txt'); RestartBot(); } else { if ($errorData == "token value failed") { AddLog2('FV FUBAR: Game Opened in Another Browser'); AddLog2('Work Will Restart in 15 Seconds'); RestartBot(); } else { if ($errorData == "token too old") { AddLog2('FV FUBAR: Your Session Has Expired'); AddLog2('Work Will Restart in 15 Seconds'); RestartBot(); } else { if ($errorType == 29) { AddLog2('FV FUBAR: Server Sequence Was Reset'); DoInit(); } else { $res = "Error: " . $errorType . " " . $errorData; DoInit(); } } } } } else { if (!isset($amf2->_bodys[0]->_value['data'][0])) { echo "\n*****\nError:\n BAD AMF REPLY - Possible Server problem or farm badly out of sync\n*****\n"; $res = "BAD AMF REPLY (OOS?)"; } else { if ($errorType == '' && $errorData == '') { $res = 'OK'; } else { $res = 'Unknown'; } } } //if (isset($amf2->_bodys[0]->_value['data'][0])) { //$res = $errorType . " " . $errorData; //} //} return $res; }
function CheckAMF2Response($amf2) { if (@$amf2->_bodys[0]->_value['errorType'] != 0) { if ($amf2->_bodys[0]->_value['errorData'] == "There is a new version of the farm game released") { AddLog2('FV UPDATE: New Version of FV Released'); AddLog2('Work Will Restart in 15 Seconds'); @unlink('sqlite_check.txt'); die; } else { if ($amf2->_bodys[0]->_value['errorData'] == "token value failed") { AddLog2('FV FUBAR: Game Opened in Another Browser'); AddLog2('Work Will Restart in 15 Seconds'); die; } else { if ($amf2->_bodys[0]->_value['errorData'] == "token too old") { AddLog2('FV FUBAR: Your Session Has Expired'); AddLog2('Work Will Restart in 15 Seconds'); die; } else { if ($amf2->_bodys[0]->_value['errorType'] == 29) { AddLog2('FV FUBAR: Server Sequence Was Reset'); $_SESSION['sequence'] = 0; } else { $res = "Error: " . $amf2->_bodys[0]->_value['errorType'] . " " . $amf2->_bodys[0]->_value['errorData']; DoInit(); } } } } } else { if (!isset($amf2->_bodys[0]->_value['data'][0])) { $res = "BAD AMF REPLY (OOS?)"; } else { if (isset($amf2->_bodys[0]->_value['data'][0]['data']) && $amf2->_bodys[0]->_value['data'][0]['data'] == 'success') { $res = 'OK'; } else { if (isset($amf2->_bodys[0]->_value['data'][0]['data']) && $amf2->_bodys[0]->_value['data'][0]['data'] == '6uccess') { $res = 'OK'; } else { if (isset($amf2->_bodys[0]->_value['data'][0]['errorType']) && $amf2->_bodys[0]->_value['data'][0]['errorType'] != 0) { $res = $amf2->_bodys[0]->_value['data'][0]['errorType'] . " " . $amf2->_bodys[0]->_value['data'][0]['errorData'] . ' ' . $amf2->_bodys[0]->_value['data'][0]['data']['error']; } else { if (isset($amf2->_bodys[0]->_value['data'][0]['data']['error']) && strlen($amf2->_bodys[0]->_value['data'][0]['data']['error']) > 0) { $res = $amf2->_bodys[0]->_value['data'][0]['data']['error']; } else { $res = 'OK'; } } } } } } return $res; }
private function _fvFarmWork($items, $action = 'harvest') { $count = count($items); if ($count > 0) { $i = 0; $amf = ''; foreach ($items as $plot) { if ($action == 'harvest') { $pUnit = Units_GetUnitByName($plot['itemName'], true); $Seed = $plot['itemName']; $LastSeed = $Seed; if ($this->currbushel != $pUnit['bushelItemCode']) { $this->_fvDoBushels($pUnit['bushelItemCode']); } } $amf = CreateMultAMFRequest($amf, $i, $action, 'WorldService.performAction'); $amf->_bodys[0]->_value[1][$i]['params'][1] = $plot; $amf->_bodys[0]->_value[1][$i]['params'][2] = array(); $amf->_bodys[0]->_value[1][$i]['params'][2][0]['energyCost'] = 0; $prealname = trim(Units_GetRealnameByName($plot['itemName'])); if (@(!$plotsstring)) { $plotsstring = $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } else { $plotsstring = $plotsstring . ", " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } if (@(!$OKstring)) { $OKstring = ucfirst($action) . " " . $prealname . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } else { $OKstring = $OKstring . "\r\n" . ucfirst($action) . " " . $plot['itemName'] . " " . $plot['position']['x'] . '-' . $plot['position']['y']; } $i++; if ($i == $this->botspeed || $i >= $count) { $count -= $i; $i = 0; AddLog2('fvFarmer: ' . ucfirst($action) . " " . $plotsstring); $res = RequestAMF($amf, true); $amf2 = $res['amf2']; $amf = ''; if ($res['res'] === 'OK') { AddLog2("fvFarmer Result: " . $res['res']); foreach ($amf2->_bodys[0]->_value['data'][0]['data'] as $result) { if (isset($result['data']['foundBushel'])) { $crop = $result['data']['foundBushel']['bushelCode']; $cUnit = Units_GetUnitByCode($crop, true); AddLog2('fvFarmer: Found Bushel ' . $cUnit['realname']); if ($result['data']['foundBushel']['bushelAddedToStall'] == 1) { $this->fmBushels[] = $crop; } } } } else { if ($res['res']) { AddLog("fvFarmer Error: " . $res['res'] . " on {$OKstring}"); if (intval($res['res']) == 29 || intval($res['res']) == 28) { DoInit(); } } } unset($plotsstring, $OKstring); } } } }
private function _fvFarmLimits() { //Go Through All Objects on the Farm and Get Counts for Items foreach (GetObjects() as $object) { if ($object['className'] != 'MysterySeedling') { $uCode = Units_GetCodeByName($object['itemName']); if (isset($this->fbFarmLims[$uCode])) { @$items[$uCode]['count']++; @($items[$uCode]['object'][] = $object); } } else { $uCode = Units_GetNameByCode($object['seedType']); if (isset($this->fbFarmLims['tree_' . $object['seedType']])) { @$items['tree_' . $object['seedType']]['count']++; @($items['tree_' . $object['seedType']]['object'][] = $object); } } } if (empty($items)) { return; } AddLog2('fvTools: Applying Farm Limits'); foreach ($items as $key => $item) { if ($this->fbFarmLims[$key] < $item['count']) { array_splice($item['object'], $item['count'] - $this->fbFarmLims[$key]); if (!empty($item['object'])) { foreach ($item['object'] as $object) { $newitems[] = $object; } } } } $amfcount = 0; $amf = ''; foreach ($newitems as $object) { $amf = $this->_fvCreateMultAMFRequest($amf, $amfcount, 'sell', 'WorldService.performAction'); $amf->_bodys[0]->_value[1][$amfcount]['params'][1] = $object; $amf->_bodys[0]->_value[1][$amfcount]['params'][2] = array(); $realname = Units_GetRealnameByName($object['itemName']); $tmpArray[$amfcount]['realname'] = $realname; if ($amfcount < $this->botspeed - 1) { $amfcount++; continue; } $amf2 = $this->_fvAMFSend($amf); $amf = ''; $amfcount = 0; if ($amf2 === false) { DoInit(); continue; } foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) { $resp = $returned['errorType']; $err = $returned['errorData']; if ($resp == 0) { AddLog2('[' . $key . '] Sold: ' . $tmpArray[$key]['realname'] . ' - Result: ' . $this->zErrCGen[$resp]); } else { AddLog2('fvTools Error: ' . $tmpArray[$key]['realname'] . " Code: " . $resp . ' - ' . $err); } } if ($this->reload === true) { DoInit(); $this->reload = false; } } if (!empty($amf)) { $amf2 = $this->_fvAMFSend($amf); if ($amf2 === false) { continue; } foreach ($amf2->_bodys[0]->_value['data'] as $key => $returned) { $resp = $returned['errorType']; $err = $returned['errorData']; if ($resp == 0) { AddLog2('[' . $key . '] Sold: ' . $tmpArray[$key]['realname'] . ' - Result: ' . $this->zErrCGen[$resp]); } else { AddLog2('fvTools Error: ' . $tmpArray[$key]['realname'] . " Code: " . $resp . ' - ' . $err); } } if ($this->reload === true) { DoInit(); $this->reload = false; } } }