Hello.
I have connected my user database to sfs.
i have a field named "XP"
i Want a leader board base on this xp. how can i achieve top 10 xp of my-sql database (best performance)?
is it a matter of SQL-Query? or SFS has some build in codes to help me through this?
tanks
How To Make A Leaderboard?
Re: How To Make A Leaderboard?
Hi,
your question suggests that you don't have much experience with databases and SQL, am I wrong?
If so I would recommend investing some time studying how MySQL works, learning the basics of SQL and experimenting a bit with it before venturing into more complex stuff.
Once you've done that you can easily apply what you have learned in SmartFoxServer following these tutorials:
http://docs2x.smartfoxserver.com/Gettin ... wtos#item2
http://docs2x.smartfoxserver.com/Develo ... se-recipes
cheers
your question suggests that you don't have much experience with databases and SQL, am I wrong?
If so I would recommend investing some time studying how MySQL works, learning the basics of SQL and experimenting a bit with it before venturing into more complex stuff.
Once you've done that you can easily apply what you have learned in SmartFoxServer following these tutorials:
http://docs2x.smartfoxserver.com/Gettin ... wtos#item2
http://docs2x.smartfoxserver.com/Develo ... se-recipes
cheers
Re: How To Make A Leaderboard?
Tanks, but i've already connected MyDb to SmartFox And i have a bunch of users who have "xp" in db.
i've just wonder if sfs already implemented a component like "SignUp Extension" that can make implementing leader board fairy easy.
so i think i should implement leader board like following:
1. create a table named top10 and push first 10 high xp's in it
2. every time i update a user's xp, i should check his/her xp against top 10.
is it the right way?
i've just wonder if sfs already implemented a component like "SignUp Extension" that can make implementing leader board fairy easy.
so i think i should implement leader board like following:
1. create a table named top10 and push first 10 high xp's in it
2. every time i update a user's xp, i should check his/her xp against top 10.
is it the right way?
Re: How To Make A Leaderboard?
armanbm wrote:
1. create a table named top10 and push first 10 high xp's in it
2. every time i update a user's xp, i should check his/her xp against top 10.
is it the right way?
Yes it is the right way.
Cheers
Re: How To Make A Leaderboard?
armanbm wrote:so i think i should implement leader board like following:
1. create a table named top10 and push first 10 high xp's in it
2. every time i update a user's xp, i should check his/her xp against top 10.
is it the right way?
Here is a simple way...
Make XP a index in your database, once the users EXP is updated, SELECT with a ascending order by exp LIMIT 9 where exp > user exp to select nine players with exp higher than your player then select your player too. When displaying the values, reverse the array. Viola... Users exp and nine users with better score than him.
Or, you could just select the top nine and the user, then sort and display that.
There is no need to create a top10 table. Just index EXP and do the top 10/20/etc via select and sorting by exp. If you need high performance and your leaderboard gets a lot of hits, just cache the selects and set them to expire after like ten minutes or a one hour cron.
Re: How To Make A Leaderboard?
My explanation might have sounded complicated, but it's as simple as this in my DB...
"SELECT * FROM users ORDER BY exp DESC LIMIT 10"
"SELECT * FROM users ORDER BY exp DESC LIMIT 10"
Who is online
Users browsing this forum: No registered users and 54 guests