[Mysql] position.
#1

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.)
Reply
#2

Look it:
http://forum.sa-mp.com/showthread.ph...qlite+top+list
Reply
#3

Here is not mysql.
Reply
#4

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.
Reply
#5

Exactly what I said TheKiller.
To adapt SQLite to MySQL is basically all the similar, try!
Reply
#6

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...
Reply
#7

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.
Reply
#8

Then i please you,maybe can show how it look be.
Reply
#9

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" );
Reply
#10

Thanks.And what i have to do next?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)