[Mysql] position. - 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] position. (
/showthread.php?tid=282376)
[Mysql] position. -
budelis - 10.09.2011
Hi all.I want to ask.How to get player position by score of all registred players?for example in database is 4 registered players:
pawn Код:
1.Player1 - 4000XP
2.Player2 - 3000XP
3.Player3 - 1000XP(ME)
4.Player4 - 200XP
Your position is 3 with 1000 XP
(i only need how to get position with mysql.)
Re: [Mysql] position. -
[M]onsieur - 10.09.2011
Look it:
http://forum.sa-mp.com/showthread.ph...qlite+top+list
Re: [Mysql] position. -
budelis - 10.09.2011
Here is not mysql.
Re: [Mysql] position. -
[HiC]TheKiller - 10.09.2011
MySQL is very similar to SQLite, the queries are the exact same. I'm sure you can actually do something for once and edit the tutorial at least rather then getting someone else to do it for you. The functions are pretty much the same, you need to learn how to do it yourself.
Re: [Mysql] position. -
[M]onsieur - 10.09.2011
Exactly what I said TheKiller.
To adapt SQLite to MySQL is basically all the similar, try!
Re: [Mysql] position. -
budelis - 11.09.2011
But now i do with mysql,and i try to do it myself:
pawn Код:
new Query[ 100 ];
format(Query,sizeof(Query),"SELECT `Exp` FROM `playerdata` ORDER BY `Exp` DESC LIMIT %d", ReturnUserCount());
mysql_query(Query);
mysql_store_result();
new ID,tmpStr[64];
while(mysql_retrieve_row())
{
ID ++;
new scorevariable[5];
mysql_fetch_field_row(scorevariable, "Exp");
format(tmpStr, sizeof(tmpStr), "Your position is %d with %d XP",ID,strval(scorevariable));
}
mysql_free_result();
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_MSGBOX, "players top10", tmpStr, "OK", "");
return 1;
}
But this is not work...
Re: [Mysql] position. -
[HiC]TheKiller - 11.09.2011
I don't understand why you are having a LIMIT on the SQL query when you are returning the whole user base. You're not returning a single result, you're returning everyone's position.
Re: [Mysql] position. -
budelis - 11.09.2011
Then i please you,maybe can show how it look be.
Re: [Mysql] position. -
Retardedwolf - 11.09.2011
pawn Код:
format( Query, sizeof( Query ), "SELECT exp FROM playerdata ORDER BY exp" );
or just simply
pawn Код:
mysql_query( "SELECT exp FROM playerdata ORDER BY exp" );
Re: [Mysql] position. -
budelis - 11.09.2011
Thanks.And what i have to do next?