Untitled
unknown
plain_text
3 years ago
2.0 kB
12
Indexable
void checkauto() {
while (true) {
Sleep(300);
for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) {
if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL or pInfo(currentPeer)->world == "" or pInfo(currentPeer)->world == "EXIT") continue;
if (pInfo(currentPeer)->autofarm) {
int block = pInfo(currentPeer)->selected;
int c_ = 0;
modify_inventory(currentPeer, block, c_);
if (c_ < 1) pInfo(currentPeer)->autofarm = 0, pInfo(currentPeer)->selected = 0; // envanterde yoksa
string name_ = pInfo(currentPeer)->world;
vector<World>::iterator p = find_if(worlds.begin(), worlds.end(), [name_](const World& a) { return a.name == name_; });
if (p != worlds.end()) {
int playerx = pInfo(currentPeer)->x / 32 + (pInfo(currentPeer)->state == 16 ? -1 : 1); // oyuncunun x değeri + 1
int playery = pInfo(currentPeer)->y / 32 + (pInfo(currentPeer)->y / 32 < pInfo(currentPeer)->y / 32 ? -1 : 1); // oyuncunun y değeri + 1
int location = x / 32 + (y / 32 * 100); // x ve y değerlerini toparla
World* world_ = &worlds[p - worlds.begin()];
WorldBlock* block_ = &world_->blocks[location]; // blok verilerini çek
if (block_->fg != 0) { // blok sıfır değilse yapılacak işlem
edit_tile(currentPeer, pInfo(currentPeer)->x / 32 + (pInfo(currentPeer)->state == 16 ? -1 : 1), pInfo(currentPeer)->y / 32, 18);
}
else { // blok sıfır ise yapılacak işlem
edit_tile(currentPeer, pInfo(currentPeer)->x / 32 + (pInfo(currentPeer)->state == 16 ? -1 : 1), pInfo(currentPeer)->y / 32, block);
}
}
}
}
}
}Editor is loading...