Untitled
else if (actual_command.substr(0, 5) == "/pay ") { vector<string> a_ = explode(" ", cmd); if (a_.size() != 3) return; if (not isdigit(a_[2][0])) return; int gemcount = atoi(a_[2].c_str()); string player = a_[1].c_str(); pi(peer)->last_wrenched = a_[1].c_str(); if (to_lower(pi(peer)->tankIDName) == to_lower(pi(peer)->last_wrenched)) { gamepacket_t uyar; uyar.Insert("OnConsoleMessage"); uyar.Insert("You can't send gems yourself!"); uyar.CreatePacket(peer); return; } for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue; if (to_lower(pi(currentPeer)->tankIDName) == to_lower(pi(peer)->last_wrenched)) { if (pi(peer)->gems >= gemcount) { if (gemcount <= 50) { gamepacket_t c; c.Insert("OnConsoleMessage"); c.Insert("You can't send gems lower than 50 gems!"); c.CreatePacket(peer); break; } if (gemcount < 100000000) { pi(peer)->gems -= gemcount; pi(currentPeer)->gems += gemcount; gamepacket_t g; g.Insert("OnSetBux"); g.Insert(pi(peer)->gems); g.Insert(0); g.Insert((pi(peer)->supp >= 1) ? 1 : 0); if (pi(peer)->supp >= 2) { g.Insert((float)33796, (float)1, (float)0); } g.CreatePacket(peer); gamepacket_t g2; g2.Insert("OnSetBux"); g2.Insert(pi(currentPeer)->gems); g2.Insert(0); g2.Insert((pi(currentPeer)->supp >= 1) ? 1 : 0); if (pi(currentPeer)->supp >= 2) { g2.Insert((float)33796, (float)1, (float)0); } g2.CreatePacket(currentPeer); gamepacket_t p; p.Insert("OnConsoleMessage"), p.Insert(">> `2" + to_string(gemcount) + "$ `ogems `$" + pi(currentPeer)->tankIDName + "`` sent!"); p.CreatePacket(peer); gamepacket_t p4; p4.Insert("OnConsoleMessage"), p4.Insert(">> `$" + pi(peer)->tankIDName + "`o sent `2" + to_string(gemcount) + "`` to you!"); p4.CreatePacket(currentPeer); ServerLog(pi(peer)->tankIDName + " paid " + to_string(gemcount) + " gems to " + pi(currentPeer)->tankIDName); save_player(pi(peer)); save_player(pi(currentPeer)); } else { gamepacket_t d; d.Insert("OnConsoleMessage"); d.Insert("You can't send over than 1.000.000.000 gems"); d.CreatePacket(peer); break; } } else { break; } } } } else if (actual_command == "/mods") { string mods = "", a = ""; int count = 0; for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { if (currentPeer->state != ENET_PEER_STATE_CONNECTED or currentPeer->data == NULL) continue; if (pi(currentPeer)->m_h == 1) continue; if (pi(currentPeer)->invis == true) continue; if (perm(peer, MOD)) { count++; mods += "" + a + (count == 1 ? "" : ", ") + "" + r_color(pi(currentPeer)->rank) + pi(currentPeer)->tankIDName + "``"; } } gamepacket_t p; p.Insert("OnConsoleMessage"); p.Insert("Mods online: " + (mods != "" ? mods : "(All are hidden)") + "`o.``"); p.CreatePacket(peer); } else if (actual_command.substr(0, 9) == "/ecoscan " && perm(peer, DEV)) { if (last_scan + 180000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) { last_scan = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count(); } else { int kiekDar = (last_scan + 180000 - (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) / 1000; gamepacket_t amy; amy.Insert("OnConsoleMessage"); amy.Insert("`oSomeone already scanned economy, wait " + to_string(kiekDar) + " seconds before scan!"); amy.CreatePacket(peer); return; } int targetid = atoi(cmd.substr(9, cmd.length() - 9).c_str()); if (targetid < 0 || targetid > 12656) return; int itemid = 0, itemcount = 0, dropcount = 0, a = 0, b = 0; for (auto& p : directory_iterator("players")) { json j; ifstream files(p.path()); files >> j; for (const auto& get : j["inventory"]) { int id = get[0], count = get[1]; if (id == targetid) itemcount += count; } itemcount = 0; } gamepacket_t h; h.Insert("OnConsoleMessage"); h.Insert("`2Economy Scanned: `oFound " + to_string(a + b) + " " + items[targetid].name + " in total."); h.CreatePacket(peer); } else if (actual_command.substr(0, 8) == "/logged " && perm(peer, ADMIN)) { if (last_alt_check + 120000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) { last_alt_check = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count(); } else { int kiekDar = (last_alt_check + 120000 - (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count()) / 1000; gamepacket_t amy; amy.Insert("OnConsoleMessage"); amy.Insert("`oOther admin scanned alt accounts on someone, please wait " + to_string(kiekDar) + " seconds before scan!"); amy.CreatePacket(peer); return; } string target = cmd.substr(8, cmd.length() - 8).c_str(); string path_ = "players/" + target + "_.json"; json r_; ifstream f_(path_, ifstream::binary); if (f_.fail()) return; f_ >> r_; string p_ip = r_["ip"]; string p_mac = r_["mac"]; string p_rid = r_["rid"]; string player = ""; for (auto& p : directory_iterator("players")) { json j; ifstream files(p.path()); files >> j; string c_ip = j["ip"]; string c_nick = j["name"]; string c_mac = j["mac"]; string c_rid = j["rid"]; if (p_ip == c_ip) { if (c_nick != target && player.find(c_nick) == string::npos) player += c_nick + ","; } if (p_rid == c_rid) { if (c_nick != target && player.find(c_nick) == string::npos) player += c_nick + ","; } if (p_mac == c_mac && c_mac != "02:00:00:00:00:00") { if (c_nick != target && player.find(c_nick) == string::npos) player += c_nick + ","; } files.close(); } gamepacket_t k; k.Insert("OnConsoleMessage"); k.Insert("Found Logons: " + player + ""); k.CreatePacket(peer); f_.close(); }
Leave a Comment