Guest User

Untitled

a guest
Jan 23rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. <?php
  2. $this->AddHook('produce_coins', 'Produce');
  3.  
  4. function Produce($bot)
  5. {
  6. // scripted original by GML fix by high comunity
  7. if ($bot->firstrun)
  8. return;
  9. $bot->ReloadConfig();
  10. $data = $bot->ld->GetPlSettings("Coins");
  11. if ((int)$data->Produce != 1)
  12. return;
  13.  
  14. $bot->SendMsg('Produce Coins initializing...');
  15. $bot->SendMsg('');
  16. $bot->SendMsg('Collecting Coins And Xp');
  17. $bot->SendMsg('');
  18.  
  19. $bodycheck= false;
  20. $objcounts = 1;
  21. $count = 0;
  22. $buildings = 0;
  23. $freebuildings = 0;
  24. $notready = 0;
  25. $sleeptimer = 0;
  26. $milB = array("Drydocks", "Barracks", "Hangar");
  27. foreach ($bot->fobjects as $obj)
  28. {
  29. if (in_array(strtok($obj['itemName'], ' '), $milB))
  30. {
  31. $buildings ++;
  32. if ($obj["state"] != 9)
  33. $freebuildings ++;
  34. }
  35. }
  36.  
  37. $bot->SendMsg('You have '.$buildings.' army buildings. Only '.$freebuildings.' are free.');
  38. $taskslimit = round($freebuildings/7);
  39. if ($taskslimit < 2)
  40. $taskslimit = 2;
  41. $bot->SendMsg('Task limit set to '.$taskslimit);
  42. $bot->SendMsg('');
  43.  
  44. unset($amf);
  45. while ($objcounts < 9999999) {
  46. set_time_limit(0);
  47. if ($bot->gold > 2000000000) return;
  48. $currentIndex = 0;
  49. foreach ($bot->fobjects as $obj) {
  50. set_time_limit(300);
  51. if (in_array(strtok($obj['itemName'], ' '), $milB))
  52. {
  53. $currentIndex++;
  54. if (isset($bot->error_msg)) {
  55. $bot->ReloadConfig();
  56. break;
  57. }
  58. if ($count == 0){ // add header
  59. $amf = new AMFObject("");
  60. $amf->_bodys[0] = new MessageBody();
  61. $amf->_bodys[0]->_value[0] = $bot->GetAmfHeader();
  62. $amf->_bodys[0]->targetURI = 'BaseService.dispatchBatch';
  63. $amf->_bodys[0]->responseURI = '';
  64. $amf->_bodys[0]->_value[2] = 0;
  65. }
  66.  
  67. if ($obj["state"] == 10)
  68. {
  69. if ($obj["referenceItem"] == "") {
  70. $bodycheck = add_to_amf ($bot,&$amf,$obj,&$count,1,0); // with streak
  71. $bodycheck = add_to_amf ($bot,&$amf,$obj,&$count,0,1);
  72. $objcounts++;
  73. }else{
  74. $bodycheck = add_to_amf ($bot,&$amf,$obj,&$count,0,1); // no streak
  75. }
  76. }
  77. if ($obj["state"] == 8)
  78. {
  79. $bodycheck = add_to_amf ($bot,&$amf,$obj,&$count,0,1); // no streak
  80.  
  81. }
  82. if (($count > $taskslimit) || ($currentIndex >= $buildings)){ // send # amf per send <-----
  83.  
  84. if ($bodycheck){ // only send out request if there's a body.
  85. $bot->SendMsg('> Starting '.$count.' tasks.');
  86. $serializer = new AMFSerializer();
  87. $result = $serializer->serialize($amf);
  88. $bot->SendRequest($result);
  89. $bot->SendMsg(' <<< Done '.$count.' tasks. Total '.$objcounts.' streaks.');
  90. $bodycheck = false;
  91. }else{ // otherwise don't send it out.
  92. $bot->SendMsg('+++ Buildings not ready.');
  93. $notready++;
  94. if ($notready > 7) // decrease the task if too many building not ready encounter
  95. {
  96. $notready = 0;
  97. $sleeptimer++;
  98. sleep($sleeptimer);
  99. $bot->SendMsg('-> Sleeping for '.$sleeptimer.' seconds for building to be ready.');
  100. //$bot->SendMsg('-> Tasks limit decreased to '.$taskslimit.' <-');
  101. }
  102. }
  103. unset($amf);
  104. $count = 0;
  105. }
  106. }
  107. }
  108. refresh ($bot);
  109. }
  110. }
  111.  
  112. function add_to_amf ($bot,&$amf,$obj,&$count,$streak,$itemcode) // produce locked units
  113. {
  114. $bodycheck = true;
  115. // setState body
  116. $amf->_bodys[0]->_value[1][$count]['sequence'] = $bot->GetSequense();
  117. $amf->_bodys[0]->_value[1][$count]['functionName'] = "WorldService.performAction";
  118. $amf->_bodys[0]->_value[1][$count]['params'][0] = "setState";
  119. $amf->_bodys[0]->_value[1][$count]['params'][1]['id'] = $obj['id'];
  120. $amf->_bodys[0]->_value[1][$count]['params'][1]['itemName'] = $obj['itemName'];
  121. $amf->_bodys[0]->_value[1][$count]['params'][1]['position'] = $obj['position'];
  122. if ($itemcode)
  123. $amf->_bodys[0]->_value[1][$count]['params'][2][0]['referenceItem'] = Null;
  124. $amf->_bodys[0]->_value[1][$count]['params'][1]['ch'] = $bot->ch($amf->_bodys[0]->_value[1][$count]['params'][1]);
  125. $amf->_bodys[0]->_value[1][$count]['params'][2][0]['ch'] = $bot->ch($amf->_bodys[0]->_value[1][$count]['params'][2][0]);
  126. $count++;
  127. if ($streak)
  128. {
  129. // streak bonus
  130. $streakbonus = round((($bot->level + 1) * 1.5 * 55)-1);
  131. $amf->_bodys[0]->_value[1][$count]['sequence'] = $bot->GetSequense();;
  132. $amf->_bodys[0]->_value[1][$count]['functionName'] = "UserService.streakBonus";
  133. $amf->_bodys[0]->_value[1][$count]['params'][0]['amount'] = $streakbonus;
  134. $amf->_bodys[0]->_value[1][$count]['params'][0]['maxesReached'] = 10;
  135. $count++;
  136. }
  137. return $bodycheck;
  138. }
  139.  
  140. function refresh ($bot) // initUser, slim down
  141. {
  142. $bot->SendMsg('Reloading objects...');
  143. $amf = new AMFObject("");
  144. $amf->_bodys[0] = new MessageBody();
  145. $amf->_bodys[0]->_value[0] = $bot->GetAmfHeader();
  146. $amf->_bodys[0]->targetURI = 'BaseService.dispatchBatch';
  147. $amf->_bodys[0]->responseURI = '';
  148. $amf->_bodys[0]->_value[2] = 0;
  149. $amf->_bodys[0]->_value[1][0]['sequence'] = 1;
  150. $amf->_bodys[0]->_value[1][0]['functionName'] = "UserService.initUser";
  151. $amf->_bodys[0]->_value[1][0]['params'][0] = $bot->usern;
  152.  
  153. $ret = $bot->SendRequestAMF($amf);
  154. $bod = $bot->DeserializeRetAMF($ret);
  155.  
  156. $bot->cfg = $bod;
  157. $bot->sequense = 1;
  158. $bot->fobjects = $bod->_value['data'][0]['data']['userInfo']['world']['objects'];
  159. $bot->gold = $bod->_value['data'][0]['data']['userInfo']['world']['resources']['coins'];
  160.  
  161. }
  162.  
  163. ?>`````````````````````````````````````````````````````````
Add Comment
Please, Sign In to add comment