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); }
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 GB_BuyFuel($ObjD, $GB_amount) { global $GB_tempid; if ($GB_tempid < 63000) { $GB_tempid = 63000; } $px_Setopts = LoadSavedSettings(); if (!@$px_Setopts['bot_speed']) { $vSpeed = 1; } if (@$px_Setopts['bot_speed'] < 1) { $vSpeed = 1; } else { $vSpeed = $px_Setopts['bot_speed']; } if (@$px_Setopts['bot_speed'] > 20) { $vSpeed = 8; } $vRunMainLoop = ceil($GB_amount / $vSpeed); for ($vI = 0; $vI < $vRunMainLoop; $vI++) { $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(); $vNumAction = 0; for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $GB_amount; $vJ++) { @($amf = CreateMultAMFRequest($amf, $vNumAction, '', 'FarmService.buyFuel')); $amf->_bodys[0]->_value[1][$vNumAction]['params'][0] = $ObjD['_name']; //'fuel5'; $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = true; $vNumAction++; $GB_tempid++; } $res = RequestAMF2($amf); if ($res == 'OK') { AddLog2('GiftBox: Use ' . $ObjD['_name'] . ' - Result: ' . $res . '[' . $GB_amount - $vJ . ' to Go]'); $need_reload = true; } else { AddLog2("GiftBox: Error - " . $res); return $res; } } return $res; }
function Sections_WalkRotate_Speed() { global $vAnnounceWalkRotateArray; $px_Setopts = LoadSavedSettings(); if (!@$px_Setopts['bot_speed'] || @$px_Setopts['bot_speed'] > 50 || @$px_Setopts['bot_speed'] < 1) { $vSpeed = 1; } else { $vSpeed = $px_Setopts['bot_speed']; } $vCntMoves = count($vAnnounceWalkRotateArray); $vRunMainLoop = ceil($vCntMoves / $vSpeed); for ($vI = 0; $vI < $vRunMainLoop; $vI++) { $need_reload = false; $res = 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(); unset($vMSG); $vNumAction = 0; for ($vJ = $vI * $vSpeed; $vJ < $vI * $vSpeed + $vSpeed && $vJ < $vCntMoves; $vJ++) { $o = $vAnnounceWalkRotateArray[$vJ]['o']; $vWalk = $vAnnounceWalkRotateArray[$vJ]['vWalk']; $vRotate = $vAnnounceWalkRotateArray[$vJ]['vRotate']; $amf->_bodys[0]->_value[1][$vNumAction]['params'] = array(); $amf->_bodys[0]->_value[1][$vNumAction]['params'][0] = 'move'; $amf->_bodys[0]->_value[1][$vNumAction]['params'][1] = $o; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2] = array(); $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['canWander'] = $vWalk; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['state'] = $o['state']; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['direction'] = $vRotate; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['x'] = $o['position']['x']; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['y'] = $o['position']['y']; $amf->_bodys[0]->_value[1][$vNumAction]['params'][2][0]['z'] = $o['position']['z']; $amf->_bodys[0]->_value[1][$vNumAction]['sequence'] = GetSequense(); $amf->_bodys[0]->_value[1][$vNumAction]['functionName'] = 'WorldService.performAction'; $vNumAction++; $vMSG[] = $o['position']['x'] . '/' . $o['position']['y']; } $amf->_bodys[0]->_value[2] = 0; AddLog2("Sections: Speed_WalkRotate on " . implode(' ', $vMSG)); $res = RequestAMF($amf); AddLog2("Sections: result {$res}"); if ($res === 'OK') { $need_reload = true; } } return $need_reload; }
?> <html> <head> <link rel="stylesheet" type="text/css" href="css/fBSettings.css" /> <style type="text/css"> body { background-color: #FFFFFF; } </style> </head> <body> <?php $px_Setopts = LoadSavedSettings(); fBAcctHeader(); echo '<form method="POST" id="main_form" action="index.php?userId=' . $_SESSION['userId'] . '">'; echo '<input type="hidden" name="save_action" value="1" />'; echo '<input type="hidden" name="userId" value="' . $_SESSION['userId'] . '" />'; echo '<br/>'; echo '<table width="100%">'; echo '<tr><td colspan="3" align="center" class="mainBlueTitle"><input type="submit" name="save" value="Save Changes"></td></tr>'; echo '<tr><td valign="top">'; echo '<b>Your current configuration:</b><span style="font:bold 16px serif; color:red; background-color: ;"><br><br>fBSettings v' . FB_SETTINGS_VER . '<br>fBParser v' . FB_PARSER_VER . ' </span><br><br>'; echo '</nobr><div>Timezone: <select name="timezone" title="your time zone">'; $timezonefile = './timezone.txt'; if (file_exists($timezonefile)) { $timezone = trim(file_get_contents($timezonefile)); } else { $timezone = 'America/Los_Angeles';