ReSe Posted July 19, 2012 Share Posted July 19, 2012 Hey! Im going to create nice pointsystem but im already thinking how to sort it. Script save the AccountName and PointValue of players and must sort them from biggest PointValue because i would like to get player current rank in points. I think the best is SQLlite to do this what you think? Maybe it can be easiest with another one idk. Link to comment
ReSe Posted July 19, 2012 Author Share Posted July 19, 2012 What about that idea? To get number of bigger values then one player have ? I mean we search in SQL for bigger values then our player have and that's his rank + 1 Something like that: We have 10 players with points, 5 of them have more then we so our rank is 5 + 1 = 6 so we are 6th. Script count the number with more points and then we add + 1 to it and here we are How should our dbQuery look ? Link to comment
GTX Posted July 19, 2012 Share Posted July 19, 2012 SELECT * FROM table ORDER BY points DESC This will sort everything by points and make a toplist. Link to comment
Castillo Posted July 19, 2012 Share Posted July 19, 2012 Are you sure that SQLite has that? Link to comment
GTX Posted July 19, 2012 Share Posted July 19, 2012 Oh, I'm sorry, I thought he meant MySQL. My bad. EDIT: I think it has that, I'll try. Link to comment
ReSe Posted July 19, 2012 Author Share Posted July 19, 2012 Yea SQL have it It work nice But how get the position of our player ? local sortquery = dbQuery (playerstatistic, "SELECT * FROM PlayerPoints ORDER BY points DESC") local positon = dbPoll(sortquery,-1) I don't really understand table which is created by dbPoll, how can i read a number of a row from it ? I mean i will look for same accountname and get the row number of it Link to comment
ReSe Posted July 20, 2012 Author Share Posted July 20, 2012 Ok i will try to use one of the examples. local result, numrows, errmsg = dbPoll ( qh, -1 ) local result, numrows, errmsg = dbPoll ( qh, -1 ) if numrows > 0 then for result, row in pairs ( result ) do -- by using a second loop (use it if you want to get the values of all columns the query selected): for column, value in pairs ( row ) do -- column = the mysql column of the table in the query -- value = the value of that column in this certain row end -- or without a second loop (use it if you want to handle every value in a special way): outputChatBox ( row["column"] ) -- it will output the value of the column "column" in this certain row end end How to get values in each row? Link to comment
ReSe Posted July 20, 2012 Author Share Posted July 20, 2012 Ok nvm i got it Thanks for order by Gtx :] Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now