Advertisement
LordFuton

autofarm

Feb 12th, 2023 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. void autofarming(ENetPeer* peer) {
  2. int items21 = pInfo(peer)->farmable;
  3. int c_ = 0;
  4. modify_inventory(peer, items21, c_);
  5. if (pInfo(peer)->save_time + 15 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
  6. if (pInfo(peer)->save_time != 0) {
  7. if (pInfo(peer)->autofarm == 1 && c_ >= 2) {
  8. if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) {
  9. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32, items21);
  10. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32, items21);
  11. }
  12. else if (pInfo(peer)->x / 32 == pInfo(peer)->x / 32) {
  13. if (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 || pInfo(peer)->y / 32 < pInfo(peer)->y / 32) {
  14. edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 1 : -1), 18);
  15. edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 2 : -2), 18);
  16. }
  17. }
  18. else if (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 || pInfo(peer)->y / 32 > pInfo(peer)->y / 32) {
  19. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 ? -1 : 1), 18);
  20. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 ? -2 : 2), 18);
  21. }
  22. }
  23. }
  24. pInfo(peer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
  25. }
  26. }
  27.  
  28. void autofarming2(ENetPeer* peer) {
  29. if (pInfo(peer)->autofarm == 1) {
  30. if (pInfo(peer)->save_time + 15 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
  31. if (pInfo(peer)->save_time != 0) {
  32. if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) {
  33. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32, 18);
  34. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32, 18);
  35. }
  36. else if (pInfo(peer)->x / 32 == pInfo(peer)->x / 32) {
  37. if (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 || pInfo(peer)->y / 32 < pInfo(peer)->y / 32) {
  38. edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 1 : -1), 18);
  39. edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 2 : -2), 18);
  40. }
  41. }
  42. else if (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 || pInfo(peer)->y / 32 > pInfo(peer)->y / 32) {
  43. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 ? -1 : 1), 18);
  44. edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 ? -2 : 2), 18);
  45. }
  46. }
  47. }
  48. autofarming(peer);
  49. pInfo(peer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
  50. }
  51. }
  52.  
  53. void check_auto() {
  54. while (true) {
  55. this_thread::sleep_for(chrono::milliseconds(150));
  56. for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
  57. if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
  58. if (pInfo(currentPeer)->world != "" && pInfo(currentPeer)->autofarm) {
  59. autofarming2(currentPeer);
  60. }
  61. }
  62. }
  63. }
  64.  
  65. /yang ini ada di void loop_world
  66. if (pInfo(currentPeer)->world != "" && pInfo(currentPeer)->autofarm) {
  67. if (pInfo(currentPeer)->autofarm2 == 1) {
  68. if (pInfo(currentPeer)->loop_autofarm + 2 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
  69. if (pInfo(currentPeer)->loop_autofarm != 0) {
  70. if (pInfo(currentPeer)->magnetron_id >= 1) {
  71. magfarming2(currentPeer);
  72. } else {
  73. gamepacket_t p;
  74. p.Insert("OnTalkBubble"), p.Insert(pInfo(currentPeer)->netID), p.Insert("`wMagplant 5000 `4Empty``"), p.CreatePacket(currentPeer);
  75. }
  76. }
  77. }
  78. pInfo(currentPeer)->loop_autofarm = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
  79. } else {
  80. if (pInfo(currentPeer)->loop_autofarm + 5 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
  81. if (pInfo(currentPeer)->loop_autofarm != 0) {
  82. autofarming2(currentPeer);
  83. }
  84. }
  85. pInfo(currentPeer)->loop_autofarm = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement