SA-MP Forums Archive
Mysql bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql bug (/showthread.php?tid=628474)



Mysql bug - Loinal - 10.02.2017

I have 2 players then the textdraw show the one who have less money than other

PHP код:
stock Topcash()
{
    
mysql_tquery(mysql ,"SELECT Username,Money FROM players WHERE ID ORDER BY Money LIMIT 1;""ShowBestCash","");
    return 
true;
}
forward ShowBestCash();
public 
ShowBestCash()
{
      new 
rows;
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
playername[35];
        new 
playermoney;
        new 
str[1303];
        
cache_get_value_index(00playername);
        
cache_get_value_name_int(0,"Money",playermoney);
        
cache_get_value_index_int(0,1playermoney);
        
format(strsizeof(str), "~b~~h~N~b~~h~e~b~~h~~h~w~b~~h~~h~s~w~:~y~~h~%s~w~ Is the reachest player (~r~%d~r~~h~ cash~w~)~n~~n~"playernameplayermoney);
        
TextDrawSetString(Textdraw7,str);
        
TextDrawShowForAll(Textdraw7);
    }
    return 
1;




Re: Mysql bug - kloning1 - 10.02.2017

can you show your code when server creating textdraw?

using side money ( textdraw ) you have to set the textdraw to player not to global.
i recommended use
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw


Re: Mysql bug - Vince - 10.02.2017

Default sort order is ascending. Append the DESC keyword to sort in descending order (ORDER BY money DESC).


Re: Mysql bug - Loinal - 11.02.2017

Quote:
Originally Posted by kloning1
Посмотреть сообщение
can you show your code when server creating textdraw?

using side money ( textdraw ) you have to set the textdraw to player not to global.
i recommended use
https://sampwiki.blast.hk/wiki/CreatePlayerTextDraw
Do you need my textdraw codes?


Re: Mysql bug - Loinal - 11.02.2017

Quote:
Originally Posted by Vince
Посмотреть сообщение
Default sort order is ascending. Append the DESC keyword to sort in descending order (ORDER BY money DESC).
didn't understand


Re: Mysql bug - Loinal - 11.02.2017

Any help?


Re: Mysql bug - Macronix - 11.02.2017

He means that you should add "DESC" to your mysql query.

PHP код:
mysql_tquery(mysql ,"SELECT Username,Money FROM players WHERE ID ORDER BY Money DESC LIMIT 1;""ShowBestCash",""



Re: Mysql bug - Loinal - 12.02.2017

Quote:
Originally Posted by Macronix
Посмотреть сообщение
He means that you should add "DESC" to your mysql query.

PHP код:
mysql_tquery(mysql ,"SELECT Username,Money FROM players WHERE ID ORDER BY Money DESC LIMIT 1;""ShowBestCash",""
what should i do in it?


Re: Mysql bug - Macronix - 12.02.2017

Nothing. I already added it to your query in my post. Try that line.


Re: Mysql bug - Loinal - 16.02.2017

PHP код:
 Topscore()
{
    
mysql_tquery(mysql ,"SELECT Username,Score FROM players WHERE ID ORDER BY Score DESC LIMIT 1;""ShowBestScore","");
    return 
true;
}
forward ShowBestScore();
public 
ShowBestScore()
{
      new 
rows;
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
playername[35];
        new 
playerscore;
        new 
str[1303];
        
        
cache_get_value_index(00playername);
        
cache_get_value_name_int(0,"Score",playerscore);
        
cache_get_value_index_int(0,1playerscore);

        
format(strsizeof(str), "~b~~h~N~b~~h~e~b~~h~~h~w~b~~h~~h~s~w~: Player with the most score is~y~~h~ %s~w~ have (~r~%d~r~~h~ score~w~)~n~~n~"playernameplayerscore);
        
TextDrawSetString(Textdraw7,str);
        
TextDrawShowForAll(Textdraw7);
    }
    return 
1;
}
stock Topcash()
{
    
mysql_tquery(mysql ,"SELECT Username,Money FROM players WHERE ID ORDER BY Money DESC LIMIT 1;""ShowBestCash","");
    return 
true;
}
forward ShowBestCash();
public 
ShowBestCash()
{
      new 
rows;
    
cache_get_row_count(rows);
    if(
rows)
    {
        new 
playername[35];
        new 
playermoney;
        new 
str[1303];

        
cache_get_value_index(00playername);
        
cache_get_value_name_int(0,"Money",playermoney);
        
cache_get_value_index_int(0,1playermoney);

        
format(strsizeof(str), "~b~~h~N~b~~h~e~b~~h~~h~w~b~~h~~h~s~w~:~y~~h~%s~w~ Is the reachest player (~r~%d~r~~h~ cash~w~)~n~~n~"playernameplayermoney);
        
TextDrawSetString(Textdraw7,str);
        
TextDrawShowForAll(Textdraw7);
    }
    return 
1;

Not getting the higher score or the reachest one it only get the last one who registered