Jump to content

Quest Function - Top 10 Players


Recommended Posts

  • Bot
	int _get_ranklist(lua_State* L)  
	{
		std::string Ranklist="";
		char classifica[1024]={0};
		snprintf(classifica, sizeof(classifica), "SELECT name, level FROM player.player%s WHERE account_id=(SELECT id FROM account.account%s WHERE status='OK' AND id=account_id) ORDER BY level DESC LIMIT 10;", get_table_postfix(), get_table_postfix());
		SQLMsg * res = DBManager::instance().DirectQuery(classifica);
		if (res->Get()->uiNumRows == 0) {
			M2_DELETE(res);
			lua_pushstring(L, "There aren't players now.");
			sys_err("Query: %s", classifica);
			return 1;
		}
		Ranklist+="<Top 10 Player>[ENTER][ENTER]";
		int pos=0;
		for (uint i=0; i<res->Get()->uiNumRows; i++) {
			MYSQL_ROW rows=mysql_fetch_row(res->Get()->pSQLResult);
			std::string name=std::string(rows[0]);
			if (name[0] != '[') {
				pos=i+1;
				std::string space="";
				for (unsigned s=0; s<=(25 - (int)name.length()); s++) space+=" ";
				Ranklist+=format("%d | %s%s | Lv.%s[ENTER]", pos, name.c_str(), space.c_str(), rows[1]);
			}else{
				pos=i-1;
			}
		}
		M2_DELETE(res);
		lua_pushstring(L, Ranklist.c_str());
		return 1;
	}

 

  • Metin2 Dev 1
  • Good 1

english_banner.gif

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.