void checkauto() {
while (true) {
this_thread::sleep_for(chrono::milliseconds(300));
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) {
blockkir(currentPeer);
}
}
}
}
void blockkoy(ENetPeer* peer) {
int block = pInfo(peer)->selected;
int c_ = 0;
modify_inventory(peer, block, c_);
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);
}
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);
}
}
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);
}
}
}
void blockkir(ENetPeer* peer) {
if (pInfo(peer)->autofarm == 1) {
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);
}
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);
}
}
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);
}
blockkoy(peer);
}
}
// thread baslatmak icin
threads.push_back(std::thread(checkauto));