Quote:
Originally Posted by saamp
maddinat0r, I need an answer ; I want to create a Top Players with some fields ( level, money, crimes, etc. ). The database is actually big enough ( + 500.000 accounts ). Do I have to make 3 threaded queries for all of this?
For example:
pawn Код:
// CMD:top(playerid, params) mysql_tquery(SQL, "SELECT level FROM accounts ORDER BY level DESC LIMIT 5", "TopLevel", "d", playerid); mysql_tquery(SQL, "SELECT money FROM accounts ORDER BY money DESC LIMIT 5", "TopMoney", "d", playerid); mysql_tquery(SQL, "SELECT crime FROM accounts ORDER BY crime DESC LIMIT 5", "TopCrime", "d", playerid);
pawn Код:
forward TopLevel(const playerid); public TopLevel(const playerid) { if(!IsPlayerConnected(playerid)) return 1;
// My Top Level Code ............. strcat(largeString, editedString); // ...................................... return 1; }
forward TopMoney(const playerid); public TopMoney(const playerid) { if(!IsPlayerConnected(playerid)) return 1;
// My Top Money Code ........................ strcat(largeString, editedString); // ......................................
return 1; }
forward TopCrime(const playerid); public TopCrime(const playerid) { if(!IsPlayerConnected(playerid)) return 1;
// My Top Crime Code ....................... strcat(largeString, editedString); // ......................................
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Top Players", largeString, "OK", ""); return 1; }
|
What exactly do you wish to show? If you want to show their name together with their (for example, level) then you must select the name in the SELECT part and order them as (for example, level) as you've done correctly. LIMIT will help you select only the top X (5 in this case) players so that's correct too. And yes, you'd have to make 3 different queries to do this.