Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.8 kB
0
Indexable
Never
std::vector<std::pair<std::string, int>> players;
			int lock = 0, itemcount = 0, itemid = 0, sayi = 0;
			string name = "", names = "";
			int gems = 0, opc = 0, level = 0, adml = 0, bpoi = 0;
			for (auto& p : directory_iterator("players")) {
				json j;
				ifstream files(p.path());
				files >> j;
				adml = j["adminLevel"];
				name = j["name"];
				gems = j["gems"];
				opc = j["opc"];
				level = j["level"];
				bpoi = j["bpoi"];
				lock += opc / 2;
				//lock += level / 3;
				lock += gems / 20000;
				lock += bpoi / 500;
				json a_ = j["inv"].get<json>();
				for (int i_ = 0; i_ < a_.size(); i_++) {
					itemid = a_.at(i_)["i"].get<int>();
					itemcount = a_.at(i_)["c"].get<int>();
					if (itemid == 242) {
						lock += itemcount;
					}
					if (itemid == 1796) {
						lock += itemcount * 100;
					}
					if (itemid == 7188) {
						lock += itemcount * 10000;
					}
				}
				if (level < 25) continue;
				players.push_back(std::make_pair(name, lock));
				lock = 0;
			}
			std::sort(players.begin(), players.end(), [](const std::pair<std::string, int>& a, const std::pair<std::string, int>& b) {
				return a.second > b.second;
				});
			string btn = "";
			for (const std::pair<std::string, int>& player : players) {
				if (sayi < 100) {
					btn += "\nadd_button|leader_" + player.first + "|`##"+ to_string(sayi + 1) + " `w" + player.first + "|";
					sayi++;
				}
			}
			gamepacket_t k;
			k.Insert("OnDialogRequest");
			k.Insert("\nadd_label_with_icon|big|`wLeaderboard|left|394|\nadd_spacer|small|\nadd_smalltext|`1Note: Requirement is minimum 25 level!|\nadd_textbox|`oTop 100 Richest Players of Voidtopia:|\nadd_spacer|small|" + btn +"\nadd_spacer|\nadd_button|kk|Close|\nadd_quick_exit|");
			k.CreatePacket(peer);