Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void autofarming(ENetPeer* peer) {
- int items21 = pInfo(peer)->farmable;
- int c_ = 0;
- modify_inventory(peer, items21, c_);
- if (pInfo(peer)->save_time + 15 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
- if (pInfo(peer)->save_time != 0) {
- if (pInfo(peer)->autofarm == 1 && c_ >= 2) {
- if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) {
- edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32, items21);
- edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32, items21);
- }
- else if (pInfo(peer)->x / 32 == pInfo(peer)->x / 32) {
- if (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 || pInfo(peer)->y / 32 < pInfo(peer)->y / 32) {
- edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 1 : -1), 18);
- edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 2 : -2), 18);
- }
- }
- else if (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 || pInfo(peer)->y / 32 > pInfo(peer)->y / 32) {
- 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);
- 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);
- }
- }
- }
- pInfo(peer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
- }
- }
- void autofarming2(ENetPeer* peer) {
- if (pInfo(peer)->autofarm == 1) {
- if (pInfo(peer)->save_time + 15 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
- if (pInfo(peer)->save_time != 0) {
- if (pInfo(peer)->y / 32 == pInfo(peer)->y / 32) {
- edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -1 : 1), pInfo(peer)->y / 32, 18);
- edit_tile(peer, pInfo(peer)->x / 32 + (pInfo(peer)->state == 16 ? -2 : 2), pInfo(peer)->y / 32, 18);
- }
- else if (pInfo(peer)->x / 32 == pInfo(peer)->x / 32) {
- if (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 || pInfo(peer)->y / 32 < pInfo(peer)->y / 32) {
- edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 1 : -1), 18);
- edit_tile(peer, pInfo(peer)->x / 32, pInfo(peer)->y / 32 + (pInfo(peer)->y / 32 > pInfo(peer)->y / 32 ? 2 : -2), 18);
- }
- }
- else if (pInfo(peer)->y / 32 < pInfo(peer)->y / 32 || pInfo(peer)->y / 32 > pInfo(peer)->y / 32) {
- 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);
- 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);
- }
- }
- }
- autofarming(peer);
- pInfo(peer)->save_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
- }
- }
- void check_auto() {
- while (true) {
- this_thread::sleep_for(chrono::milliseconds(150));
- for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
- if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue;
- if (pInfo(currentPeer)->world != "" && pInfo(currentPeer)->autofarm) {
- autofarming2(currentPeer);
- }
- }
- }
- }
- /yang ini ada di void loop_world
- if (pInfo(currentPeer)->world != "" && pInfo(currentPeer)->autofarm) {
- if (pInfo(currentPeer)->autofarm2 == 1) {
- if (pInfo(currentPeer)->loop_autofarm + 2 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
- if (pInfo(currentPeer)->loop_autofarm != 0) {
- if (pInfo(currentPeer)->magnetron_id >= 1) {
- magfarming2(currentPeer);
- } else {
- gamepacket_t p;
- p.Insert("OnTalkBubble"), p.Insert(pInfo(currentPeer)->netID), p.Insert("`wMagplant 5000 `4Empty``"), p.CreatePacket(currentPeer);
- }
- }
- }
- pInfo(currentPeer)->loop_autofarm = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
- } else {
- if (pInfo(currentPeer)->loop_autofarm + 5 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) {
- if (pInfo(currentPeer)->loop_autofarm != 0) {
- autofarming2(currentPeer);
- }
- }
- pInfo(currentPeer)->loop_autofarm = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement