MYSQL TOP `X` Players Dialog Example??? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MYSQL TOP `X` Players Dialog Example??? (
/showthread.php?tid=341332)
MYSQL TOP `X` Players Dialog Example??? -
nGen.SoNNy - 10.05.2012
Hello!
Can somebody give me an example of mysql top player order by ex: Score ??
in MSGBOX style dialog
REP++;
Re: MYSQL TOP `X` Players Dialog Example??? -
nGen.SoNNy - 10.05.2012
No Ideas
Re: MYSQL TOP `X` Players Dialog Example??? -
Vince - 10.05.2012
[SQL]select name, score from playertable order by score desc limit 5[/SQL]
I'm not in the mood to type out an entire function, so here's some pseudo-code.
pawn Код:
while( fetch row )
sscanf/split/explode
format tempstring
strcat output, tempstring
showplayerdialog
Edit: damn, if I'd have seen that bump earlier I wouldn't have replied at all.
Re: MYSQL TOP `X` Players Dialog Example??? -
nGen.SoNNy - 10.05.2012
Thx! and when you have a good mood type all the example!
Re: MYSQL TOP `X` Players Dialog Example??? -
SuperViper - 10.05.2012
pawn Код:
new playerData[30], playersName[MAX_PLAYER_NAME], playersScore;
mysql_query("SELECT `name`, `score` FROM `users` ORDER BY `score`");
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_row(playerData);
sscanf(playerData, "p<|>s[24]d", playersName, playersScore);
// do something with 'playersName' and 'playersScore'
}
mysql_free_result();
Re: MYSQL TOP `X` Players Dialog Example??? -
nGen.SoNNy - 10.05.2012
I will try this

Thx! REP++
EDIT: and if i want to order by score and money?
I made this but have some bugs

Can Fix this?
pawn Код:
CMD:top(playerid, params[])
{
new playerData[512], clanname[MAX_PLAYER_NAME], string[512], clankills;
mysql_query("SELECT `clanname`, `clankills` FROM `clans` ORDER BY `clankills`");
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_row(playerData);
sscanf(playerData, "p<|>s[512]d", clanname, clankills);
// do something with 'playersName' and 'playersScore'
format(string, sizeof(string), "%s\n"R"Clan: %s"W"Kills: %d", string, clanname, clankills);
//SendClientMessage(playerid, ~1, string);
ShowPlayerDialog( playerid, 1, DIALOG_STYLE_MSGBOX,"Location: Top Clans", string, "(Close)", "");
}
mysql_free_result();
return 1;
}