MySQL Top Money
#1

Hi, I'm looking for a money system top for MySQL. Can you help ?
Reply
#2

Код:
SELECT column_money FROM user_table
ORDER BY column_money DESC
Reply
#3

How Can I list ?
Reply
#4

What?

Use the above query,
With player dialogs.

https://sampwiki.blast.hk/wiki/Dialog_Styles
Reply
#5

Try...

Код:
CMD:showtop(playerid)
{
	new Cache:Result, Name[24], Money, fString[128], cString[600];
	
	Result = mysql_query(dbhandle, "SELECT column_money FROM user_table ORDER BY column_money DESC LIMIT 10");
	if(cache_num_rows())
	{
		for(new i = 0; i < cache_num_rows(); ++ i)
		{
			cache_get_field_content(i, "Column Name", Name);
			Money = cache_get_field_content_int(i, "Column Money");
			
			format(fString, sizeof fString, "Name: %s | Money: $%d,00\n", Name, Money);
			strcat(cString, fString);
		}
	}
	cache_delete(Result);
	
	ShowPlayerDialog(playerid, 555, DIALOG_STYLE_MSGBOX, "MONEY RANK", cString, "OK","");
	
	return true;
}
Reply
#6

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Try...

Код:
CMD:showtop(playerid)
{
	new Cache:Result, Name[24], Money, fString[128], cString[600];
	
	Result = mysql_query(dbhandle, "SELECT column_money FROM user_table ORDER BY column_money DESC LIMIT 10");
	if(cache_num_rows())
	{
		for(new i = 0; i < cache_num_rows(); ++ i)
		{
			cache_get_field_content(i, "Column Name", Name);
			Money = cache_get_field_content_int(i, "Column Money");
			
			format(fString, sizeof fString, "Name: %s | Money: $%d,00\n", Name, Money);
			strcat(cString, fString);
		}
	}
	cache_delete(Result);
	
	ShowPlayerDialog(playerid, 555, DIALOG_STYLE_MSGBOX, "MONEY RANK", cString, "OK","");
	
	return true;
}
Код:
warning 219: local variable "Name" shadows a variable at a preceding level
error 035: argument type mismatch (argument 3)
warning 204: symbol is assigned a value that is never used: "Name"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.


CMD:showtop(playerid)
{
	new Cache:Result, Name[24], Money, fString[128], cString[600];

	Result = mysql_query(g_SQL, "SELECT Para FROM oyuncudata ORDER BY Para DESC LIMIT 10");
	if(cache_num_rows())
	{
		for(new i = 0; i < cache_num_rows(); ++ i)
		{
			cache_get_field_content(i, "Isim", Name); // Error
			Money = cache_get_field_content_int(i, "Para");

			format(fString, sizeof fString, "Kullanıcı: %s | Para: $%s\n", Name, convertNumber(Money));
			strcat(cString, fString);
		}
	}
	cache_delete(Result);
	ShowPlayerDialog(playerid, 95959, DIALOG_STYLE_MSGBOX, "MONEY RANK", cString, "OK","");
	return true;
Reply
#7

This section isn't for requesting scripts(shame on the people who flat out gave a script), it's for getting help with scripting. Take a look at:
Asking Good Questions

On Topic: You don't need to loop through all rows to get the account with the highest amount. You can limit and ORDER By to get the richest account in the first row.
pawn Код:
SELECT Cash, Username FROM accounts ORDER BY Cash DESC LIMIT 1
Assuming you're using BlueGs MySQL plugin, use mysql_tquery to send the query. In the query callback, you can use cache_* functions to get data from the first row(ex: cache_get_field_content_int(0, "Cash").
Reply
#8

Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
SELECT Cash, Username FROM accounts ORDER BY Cash DESC LIMIT 1
Thx for correction.
Reply
#9

Thank you for your warning. Could you give me an example, I have MySQL version R39-5. I'm sorry for my bad English.

Edit: Trying to corrupt the system.
Reply
#10

Try this
PHP код:
stock GetTopMoney(rank)
{
    new 
Cache:result mysql_query(connectionHandle"SELECT `column_money`, `column_name` FROM `table_users` ORDER BY `column_money` DESC");
    new 
playername[24], money cache_get_row_int(rank-10);
    
cache_get_row(rank-11playername24);
    
cache_delete(result);
    new 
string[24+12]; format(stringsizeof(string), "%s|%d"playernamemoney);
    return 
string;

Usage:
PHP код:
new moneyname[24];
sscanf(GetTopMoney(1), "p<|>s[24]i"namemoney); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)