Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $this->AddHook('produce_coins', 'Produce');
- function Produce($bot)
- {
- // scripted edited by high comunty original by GML
- if ($bot->firstrun)
- return;
- $bot->ReloadConfig();
- $data = $bot->ld->GetPlSettings("Coins");
- if ((int)$data->Produce != 1)
- return;
- $bot->SendMsg('Produce Coins initializing...');
- $bot->SendMsg('');
- $bot->SendMsg('Collecting Coins And Xp');
- $bot->SendMsg('');
- $bodycheck= false;
- $objcounts = 1;
- $count = 0;
- $buildings = 0;
- $freebuildings = 0;
- $notready = 0;
- $sleeptimer = 0;
- $milB = array("Drydocks", "Barracks", "Hangar");
- foreach ($bot->fobjects as $obj)
- {
- if (in_array(strtok($obj['itemName'], ' '), $milB))
- {
- $buildings ++;
- if ($obj["state"] != 9)
- $freebuildings ++;
- }
- }
- $bot->SendMsg('You have '.$buildings.' army buildings. Only
- '.$freebuildings.' are free.');
- $taskslimit = round($freebuildings/7);
- if ($taskslimit < 2)
- $taskslimit = 2;
- $bot->SendMsg('Task limit set to '.$taskslimit);
- $bot->SendMsg('');
- unset($amf);
- while ($objcounts < 9999999) {
- set_time_limit(0);
- if ($bot->gold > 2000000000) return;
- $currentIndex = 0;
- foreach ($bot->fobjects as $obj) {
- set_time_limit(200);
- if (in_array(strtok($obj['itemName'], ' '), $milB))
- {
- $currentIndex++;
- if (isset($bot->error_msg)) {
- $bot->ReloadConfig();
- break;
- }
- if ($count == 0){ // add header
- $amf = new AMFObject("");
- $amf->_bodys[0] = new MessageBody();
- $amf->_bodys[0]->_value[0] =
- $bot->GetAmfHeader();
- $amf->_bodys[0]->targetURI =
- 'BaseService.dispatchBatch';
- $amf->_bodys[0]->responseURI = '';
- $amf->_bodys[0]->_value[2] = 0;
- }
- if ($obj["state"] == 10)
- {
- if ($obj["referenceItem"] == "") {
- $bodycheck = add_to_amf
- ($bot,&$amf,$obj,&$count,1,0); // with streak
- $bodycheck = add_to_amf
- ($bot,&$amf,$obj,&$count,0,1);
- $objcounts++;
- }else{
- $bodycheck = add_to_amf
- ($bot,&$amf,$obj,&$count,0,1); // no streak
- }
- }
- if ($obj["state"] == 8)
- {
- $bodycheck = add_to_amf
- ($bot,&$amf,$obj,&$count,0,1); // no streak
- }
- if (($count > $taskslimit) || ($currentIndex >=
- $buildings)){ // send # amf per send <-----
- if ($bodycheck){ // only send out
- request if there's a body.
- $bot->SendMsg('> Starting '.$count.'
- tasks.');
- $serializer = new AMFSerializer();
- $result = $serializer->serialize($amf);
- $bot->SendRequest($result);
- $bot->SendMsg(' <<< Done '.$count.'
- tasks. Total '.$objcounts.' streaks.');
- $bodycheck = false;
- }else{ // otherwise don't
- send it out.
- $bot->SendMsg('+++ Buildings not
- ready.');
- $notready++;
- if ($notready > 7) //
- decrease the task if too many building not ready encounter
- {
- $notready = 0;
- $sleeptimer++;
- sleep($sleeptimer);
- $bot->SendMsg('-> Sleeping for
- '.$sleeptimer.' seconds for building to be ready.');
- //$bot->SendMsg('-> Tasks limit
- decreased to '.$taskslimit.' <-');
- }
- }
- unset($amf);
- $count = 0;
- }
- }
- }
- refresh ($bot);
- }
- }
Add Comment
Please, Sign In to add comment