SA-MP Forums Archive
Get the second best SQLite score - 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: Get the second best SQLite score (/showthread.php?tid=622577)



Get the second best SQLite score - BrianFaria - 24.11.2016

Hello, well, I have a doubt, here, in this code that I leave you I get the first 15 users of the table, that is, the top. What I want to know is how I get the stats of the second best user, and the third and so, but only individually and not all together and ordered, I do not know if I explain, thank you.

Код:
format(Query,sizeof(Query),"SELECT `Nick` FROM `Usuarios` ORDER BY (`Score` * 1) DESC limit 15");
resultado = db_query(BaseDeDatos,Query);
For example the first best "score" would go in this textdraw

Код:
Textdraw5 = TextDrawCreate (122.234283, 356.492949, "[S] peed_.");
TextDrawLetterSize (Textdraw5, 0.199341, 1.337499);
TextDrawAlignment (Textdraw5, 1);
TextDrawColor (Textdraw5, -1);
TextDrawSetShadow (Textdraw5, 0);
TextDrawSetOutline (Textdraw5, 1);
TextDrawBackgroundColor (Textdraw5, 51);
TextDrawFont (Textdraw5, 2);
TextDrawSetProportional (Textdraw5, 1);



Re: Get the second best SQLite score - Konstantinos - 24.11.2016

pawn Код:
SELECT Nick FROM Usuarios GROUP BY Score ORDER BY Score DESC LIMIT 1 OFFSET N;
where N = nth - 1. Since offset starts from 0, the 2nd highest score is OFFSET 1.


Respuesta: Get the second best SQLite score - BrianFaria - 25.11.2016

Код:
CALLBACK: ActualizarTds(playerid)
{
	new asdasdasd[87];
	format(asdasdasd,sizeof(asdasdasd),"~w~%s",); //Here would have to leave the first nick of the best score sqlite
	TextDrawSetString(prahxdxd5[playerid], asdasdasd);
	TextDrawShowForPlayer(playerid, prahxdxd5[playerid]);
    new Query[356];
    new DBResult:resultado;
    format(Query,sizeof(Query),"SELECT Nick FROM Usuarios GROUP BY Score ORDER BY Score DESC LIMIT 1 OFFSET N;");
	resultado = db_query(BaseDeDatos,Query);
}
And the code is not working at all


Re: Get the second best SQLite score - Vince - 25.11.2016

Uhm yeah, you're supposed to replace N with the ranking number.