Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.9 kB
3
Indexable
Never
// source.cpp oyuncu info buton

else if (cch.find("action|dialog_return\ndialog_name|\nbuttonClicked|leader_") != string::npos) {
								string target = cch.substr(59, cch.length() - 59).c_str();
								int lock = 0, itemcount = 0, itemid = 0, sayi = 0;
								string name = "", names = "";
								int gems = 0, opc = 0, level = 0, adml = 0, bpoi = 0;
								int dl = 0, bgl = 0;

								json j;
								ifstream files("players/"+ target +"_.json");
								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;
										dl += itemcount * 100;
									}
									if (itemid == 7188) {
										lock += itemcount * 10000;
										bgl += itemcount * 10000;
									}
								}
								gamepacket_t h;
								h.Insert("OnDialogRequest");
								h.Insert("\nadd_label|big|`w" + name + "|left||\nadd_spacer|small|\nadd_textbox|`oAccount worth: `$" + to_string(lock) + " Locks``|\nadd_spacer|small|\nadd_label_with_icon|small|`oGems: `$" + to_string(gems) + "|left|112|\nadd_spacer|small|\nadd_label_with_icon|small|`oBlue Gem Lock: `$" + to_string(bgl) + "|left|7188|\nadd_label_with_icon|small|`oDiamond Lock: `$" + to_string(dl) + "|left|1796|\nadd_spacer|small|\nadd_label_with_icon|small|`oOnline Point Currency: `$" + to_string(opc) + "|left|10668|\nadd_spacer|small|\nadd_quick_exit|\nadd_button|s|Close|");
								h.CreatePacket(peer);
							}

// world.h leader buton social

if (b_ == "leaderboard") {
				int sayi = 0;
				if (playerLocks.empty()) break;
				std::vector<std::pair<std::string, int>> players(playerLocks.begin(), playerLocks.end());
				std::partial_sort(players.begin(), players.begin() + 100, players.end(),
					[](const std::pair<std::string, int>& a, const std::pair<std::string, int>& b) {
						return a.second > b.second;
					});

				std::string btn = "";
				for (const std::pair<std::string, int>& player : players) {
					if (sayi < 100) {
						btn += "\nadd_button|leader_" + player.first + "|`2#" + std::to_string(sayi + 1) + " `w" + player.first + "|";
						sayi++;
					}
				}

				gamepacket_t k;
				k.Insert("OnDialogRequest");
				k.Insert("\nadd_label_with_icon|big|`9Leaderboard|left|394|\nadd_spacer|small|\nadd_smalltext|`5You need to be minimum 25 level!|\nadd_textbox|`oTop 100 Richest Players:|\nadd_spacer|small|" + btn + "\nadd_spacer|\nadd_button|kk|Close|\nadd_quick_exit|");
				k.CreatePacket(p_);
			}

//source.cpp exe baslangic
std::vector<std::pair<std::string, int>> players(playerLocks.begin(), playerLocks.end());
		for (const auto& p : std::filesystem::directory_iterator("players")) {
			json j;
			std::ifstream files(p.path());
			files >> j;

			int level = j["level"];
			if (level < 25) continue;

			std::string name = j["name"];
			int lock = j["opc"] / 2 + j["gems"] / 20000;

			json inventory = j["inv"].get<json>();
			for (const auto& item : inventory) {
				int itemid = item["i"].get<int>();
				int itemcount = item["c"].get<int>();
				if (itemid == 242) {
					lock += itemcount;
				}
				if (itemid == 1796) {
					lock += itemcount * 100;
				}
				if (itemid == 7188) {
					lock += itemcount * 10000;
				}
			}
			players.push_back(std::make_pair(name, lock));
			lock = 0;
		}
		cout << "leaderboard refreshed" << endl;

// world.h en üst koy
std::unordered_map<std::string, int> playerLocks;