Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
else if (actual_command.substr(0, 6) == "/accounts " && pInfo(peer)->adminLevel >= 2) {

			string target = to_lower(cmd.substr(6, cmd.length() - 6).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 cnick = j["name"];
                string c_nick = to_lower(cnick);
				string c_mac = j["mac"];
				string c_rid = j["rid"];
				if (p_ip == c_ip) {
					if (c_nick != target) player += c_nick + ",";
				}
				if (p_rid == c_rid) {
					if (c_nick != target) player += c_nick + ",";
				}
				if (p_mac == c_mac && c_mac != "02:00:00:00:00:00") {
					if (c_nick != target) player += c_nick + ",";
				}
				files.close();
			}
			
			gamepacket_t k;
			k.Insert("OnConsoleMessage");
			k.Insert("Found accounts: " + player + "");
			k.CreatePacket(peer);
			f_.close();
		}