Guest User

Untitled

a guest
Jan 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. <?php
  2.  
  3. $this->AddHook('produce_coins', 'Produce');
  4.  
  5. function Produce($bot)
  6.  
  7. {
  8.  
  9. // scripted edited by high comunty original by GML
  10.  
  11. if ($bot->firstrun)
  12.  
  13. return;
  14.  
  15. $bot->ReloadConfig();
  16.  
  17. $data = $bot->ld->GetPlSettings("Coins");
  18.  
  19. if ((int)$data->Produce != 1)
  20.  
  21. return;
  22.  
  23.  
  24.  
  25. $bot->SendMsg('Produce Coins initializing...');
  26.  
  27. $bot->SendMsg('');
  28.  
  29. $bot->SendMsg('Collecting Coins And Xp');
  30.  
  31. $bot->SendMsg('');
  32.  
  33.  
  34.  
  35. $bodycheck= false;
  36.  
  37. $objcounts = 1;
  38.  
  39. $count = 0;
  40.  
  41. $buildings = 0;
  42.  
  43. $freebuildings = 0;
  44.  
  45. $notready = 0;
  46.  
  47. $sleeptimer = 0;
  48.  
  49. $milB = array("Drydocks", "Barracks", "Hangar");
  50.  
  51. foreach ($bot->fobjects as $obj)
  52.  
  53. {
  54.  
  55. if (in_array(strtok($obj['itemName'], ' '), $milB))
  56.  
  57. {
  58.  
  59. $buildings ++;
  60.  
  61. if ($obj["state"] != 9)
  62.  
  63. $freebuildings ++;
  64.  
  65. }
  66.  
  67. }
  68.  
  69.  
  70.  
  71. $bot->SendMsg('You have '.$buildings.' army buildings. Only
  72.  
  73. '.$freebuildings.' are free.');
  74.  
  75. $taskslimit = round($freebuildings/7);
  76.  
  77. if ($taskslimit < 2)
  78.  
  79. $taskslimit = 2;
  80.  
  81. $bot->SendMsg('Task limit set to '.$taskslimit);
  82.  
  83. $bot->SendMsg('');
  84.  
  85.  
  86.  
  87. unset($amf);
  88.  
  89. while ($objcounts < 9999999) {
  90.  
  91. set_time_limit(0);
  92.  
  93. if ($bot->gold > 2000000000) return;
  94.  
  95. $currentIndex = 0;
  96.  
  97. foreach ($bot->fobjects as $obj) {
  98.  
  99. set_time_limit(200);
  100.  
  101. if (in_array(strtok($obj['itemName'], ' '), $milB))
  102.  
  103. {
  104.  
  105. $currentIndex++;
  106.  
  107. if (isset($bot->error_msg)) {
  108.  
  109. $bot->ReloadConfig();
  110.  
  111. break;
  112.  
  113. }
  114.  
  115. if ($count == 0){ // add header
  116.  
  117. $amf = new AMFObject("");
  118.  
  119. $amf->_bodys[0] = new MessageBody();
  120.  
  121. $amf->_bodys[0]->_value[0] =
  122.  
  123. $bot->GetAmfHeader();
  124.  
  125. $amf->_bodys[0]->targetURI =
  126.  
  127. 'BaseService.dispatchBatch';
  128.  
  129. $amf->_bodys[0]->responseURI = '';
  130.  
  131. $amf->_bodys[0]->_value[2] = 0;
  132.  
  133. }
  134.  
  135.  
  136.  
  137. if ($obj["state"] == 10)
  138.  
  139. {
  140.  
  141. if ($obj["referenceItem"] == "") {
  142.  
  143. $bodycheck = add_to_amf
  144.  
  145. ($bot,&$amf,$obj,&$count,1,0); // with streak
  146.  
  147. $bodycheck = add_to_amf
  148.  
  149. ($bot,&$amf,$obj,&$count,0,1);
  150.  
  151. $objcounts++;
  152.  
  153. }else{
  154.  
  155. $bodycheck = add_to_amf
  156.  
  157. ($bot,&$amf,$obj,&$count,0,1); // no streak
  158.  
  159. }
  160.  
  161. }
  162.  
  163. if ($obj["state"] == 8)
  164.  
  165. {
  166.  
  167. $bodycheck = add_to_amf
  168.  
  169. ($bot,&$amf,$obj,&$count,0,1); // no streak
  170.  
  171.  
  172.  
  173. }
  174.  
  175. if (($count > $taskslimit) || ($currentIndex >=
  176.  
  177. $buildings)){ // send # amf per send <-----
  178.  
  179.  
  180.  
  181. if ($bodycheck){ // only send out
  182.  
  183. request if there's a body.
  184.  
  185. $bot->SendMsg('> Starting '.$count.'
  186.  
  187. tasks.');
  188.  
  189. $serializer = new AMFSerializer();
  190.  
  191. $result = $serializer->serialize($amf);
  192.  
  193. $bot->SendRequest($result);
  194.  
  195. $bot->SendMsg(' <<< Done '.$count.'
  196.  
  197. tasks. Total '.$objcounts.' streaks.');
  198.  
  199. $bodycheck = false;
  200.  
  201. }else{ // otherwise don't
  202.  
  203. send it out.
  204.  
  205. $bot->SendMsg('+++ Buildings not
  206.  
  207. ready.');
  208.  
  209. $notready++;
  210.  
  211. if ($notready > 7) //
  212.  
  213. decrease the task if too many building not ready encounter
  214.  
  215. {
  216.  
  217. $notready = 0;
  218.  
  219. $sleeptimer++;
  220.  
  221. sleep($sleeptimer);
  222.  
  223. $bot->SendMsg('-> Sleeping for
  224.  
  225. '.$sleeptimer.' seconds for building to be ready.');
  226.  
  227. //$bot->SendMsg('-> Tasks limit
  228.  
  229. decreased to '.$taskslimit.' <-');
  230.  
  231. }
  232.  
  233. }
  234.  
  235. unset($amf);
  236.  
  237. $count = 0;
  238.  
  239. }
  240.  
  241. }
  242.  
  243. }
  244.  
  245. refresh ($bot);
  246.  
  247. }
  248.  
  249. }
Add Comment
Please, Sign In to add comment