#1

How to get player rank by for example money? For e.g there is 4 registered players: Me, player a, player b, player c. So, I want to know, in which place I am by money. Any suggestions?
Reply
#2

soz, bump
Reply
#3

PHP код:
SELECT COUNT(`name`) FROM `tableWHERE `money` < '%d'
Where %d is of course formatted with the players money. Not sure if it works.
Reply
#4

Not 100% sure what you're asking, but I assume this will help: http://thinkdiff.net/mysql/how-to-ge...g-mysql-query/
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Not 100% sure what you're asking, but I assume this will help: http://thinkdiff.net/mysql/how-to-ge...g-mysql-query/
Can anyone rewrite that code in PAWN? I think this is what I need, but the problem is that I dont understand PHP ://
Reply
#6

For those who doesnt understand, I've made this topic more simple
Reply
#7

Hi BaubaS,

When you say by money, I assume you mean you want to determine which player has X amount of money? If so you can use the following:
PHP код:
SELECT `column_nameFROM `table_nameWHERE money '%d' 
"%d" obviously being the amount of money, however if you are looking to see how many people have X amount of money, you would do the following:
PHP код:
SELECT COUNT(id) AS count FROM `table_nameGROUP BY money 
Hope it helped.

Cheers,

TJ

EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:

PHP код:
SELECT name FROM `table_nameORDER BY money DESC 
This query would return a list of players in order of money from highest to lowest, the first result would be the player who currently has the most amount of money.
Reply
#8

Quote:
Originally Posted by TTJJ
Посмотреть сообщение
Hi BaubaS,

When you say by money, I assume you mean you want to determine which player has X amount of money? If so you can use the following:
PHP код:
SELECT `column_nameFROM `table_nameWHERE money '%d' 
"%d" obviously being the amount of money, however if you are looking to see how many people have X amount of money, you would do the following:
PHP код:
SELECT COUNT(id) AS count FROM `table_nameGROUP BY money 
Hope it helped.

Cheers,

TJ

EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:

PHP код:
SELECT name FROM `table_nameORDER BY money DESC 
This query would return a list of players in order of money from highest to lowest, the first result would be the player who currently has the most amount of money.
Thanks for trying to help, but you haven't got the point. I want to get certain player (for example - player a) rank for example by money.

Quote:

EDIT: I think I actually understand a little better, you want to rank the players in order of money. In which case you would use the following:

PHP код:
SELECT name FROM `table_nameORDER BY money DESC 
This is very same what do I need ,but I need to get certain player rank, not to rank all players.
Reply
#9

Hi Again BaubaS,

I have been looking around and stumbled across a different method. However this method assumes that you already have the players money. So for instance the user is online and wants to know their money rank, you know they have 1000. You would then exectue the following query:
PHP код:
SELECT COUNT(id) AS count FROM `table_nameWHERE money '1000' 
The row "count" would then be the number of users who have more money than the user who initiated the query, giving your user their place in the table. So for instance

Player A has 1000
Player B has 2000
Player C has 3000

If player A initiates this query then it will look for all users who have more money than him and return the number of results it finds, in this case 2. Therefore player A's position is 3.

Hope that made sense.

Cheers,

TJ
Reply
#10

Quote:
Originally Posted by TTJJ
Посмотреть сообщение
Hi Again BaubaS,

I have been looking around and stumbled across a different method. However this method assumes that you already have the players money. So for instance the user is online and wants to know their money rank, you know they have 1000. You would then exectue the following query:
PHP код:
SELECT COUNT(id) AS count FROM `table_nameWHERE money '1000' 
The row "count" would then be the number of users who have more money than the user who initiated the query, giving your user their place in the table. So for instance

Player A has 1000
Player B has 2000
Player C has 3000

If player A initiates this query then it will look for all users who have more money than him and return the number of results it finds, in this case 2. Therefore player A's position is 3.

Hope that made sense.

Cheers,

TJ
Thanks again, but whats then if Player A haves 1000, but other players have 900, 800, 700, 600, 500. They will be not included in the query, right? :S Or, I should just do

SELECT COUNT(id) AS count FROM `table_name` WHERE money > '0'
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)