Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!strcmp(cmdtext, "topscore", true))
- {
- mysql_function_query(1, "SELECT `Name`, `Score` FROM `players` ORDER BY `Score` DESC LIMIT 10", false, "QUERY_OnTopScoreRet", "");
- return 1;
- }
- if(!strcmp(cmdtext, "topscorecache", true))
- {
- mysql_function_query(1, "SELECT `Name`, `Score` FROM `players` ORDER BY `Score` DESC LIMIT 10", true, "QUERY_OnTopScoreRetCache", "");
- return 1;
- }
- if(!strcmp(cmdtext, "topscorecache2", true))
- {
- mysql_function_query(1, "SELECT `Name`, `Score` FROM `players` ORDER BY `Score` DESC LIMIT 10", true, "QUERY_OnTopScoreRetCache2", "");
- return 1;
- }
- return 0;
- }
- forward QUERY_OnTopScoreRet();
- public QUERY_OnTopScoreRet()
- {
- mysql_store_result();
- new iIterator = 1, iScore, szName[MAX_PLAYER_NAME+1], szUnload[64];
- while(mysql_fetch_row_format(szUnload))
- {
- // This code will repeat ten times.
- sscanf(szUnload, "p<|>s[24]i", szName, iScore);
- format(szUnload, sizeof(szUnload), "#%d - %s (%i)", iIterator, szName, iScore);
- print(szUnload);
- iIterator++;
- }
- mysql_free_result();
- }
- forward QUERY_OnTopScoreRetCache();
- public QUERY_OnTopScoreRetCache()
- {
- new rows, fields;
- cache_get_data(rows, fields);
- new iIterator, iScore, szName[MAX_PLAYER_NAME+1], szUnload[64];
- while(iIterator < rows)
- {
- cache_get_row(iIterator, 1, szName); // Get score first
- iScore = strval(szName);
- cache_get_row(iIterator, 0, szName);
- format(szUnload, sizeof(szUnload), "#%d - %s (%i)", iIterator+1, szName, iScore);
- print(szUnload);
- iIterator++;
- }
- }
- forward QUERY_OnTopScoreRetCache2();
- public QUERY_OnTopScoreRetCache2()
- {
- new rows, fields;
- cache_get_data(rows, fields);
- new iIterator, iScore, szName[MAX_PLAYER_NAME+1], szUnload[64];
- while(iIterator < rows)
- {
- // Get score first
- cache_get_field_content(iIterator, "Score", szName);
- iScore = strval(szName);
- // Now we can re-use the szName string
- cache_get_field_content(iIterator, "Name", szName);
- format(szUnload, sizeof(szUnload), "#%d - %s (%i)", iIterator+1, szName, iScore);
- print(szUnload);
- iIterator++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment