kuwalda Posted July 18, 2014 Share Posted July 18, 2014 So I have mysql table which holds basiclly 2 main values: playerName and recordMap. Lets say I have 20 racing maps. If any player got time record on 11 maps, he is defined as "king", because noone can beat him(max map records for others is 9). So I have 2 main questions: * How can I count who is the "king"? Which player has the most map records? (mysql) * How can I count it with LUA? The main problem for me is that I understand SQL, but I can`t think of any resource efficient way of doing this. Any help would be appriciated. Link to comment
12p Posted July 18, 2014 Share Posted July 18, 2014 Wow, really? It's not hard at all 1. Add a value "topTimeCount" to every player row in the table 2. Make it so when a player beats a top time, that value is increased by 1 3. Make it so when a player loses his top time, the value is decreased by 1 4. Sort them by that value. You're done. Link to comment
tosfera Posted July 19, 2014 Share Posted July 19, 2014 Wow, really? It's not hard at all 1. Add a value "topTimeCount" to every player row in the table 2. Make it so when a player beats a top time, that value is increased by 1 3. Make it so when a player loses his top time, the value is decreased by 1 4. Sort them by that value. You're done. That's quite hard, because the times of a race is being saved as a new row ( top 5, if I'm right ). So he can just use the COUNT() function from SQL to actually get the numbers back. Just add the COUNT(*) in the where class, order it DESC and limit it to 0,1 so you only get the 'king'. Also add the group by for the map ( so you only get 1 value of every map ) and add a order by value for the time. ^^ Link to comment
12p Posted July 19, 2014 Share Posted July 19, 2014 He can make another table for the values I said. Race has a built-in event used when the player beats a top time, so I don't see the problem. 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