AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   SQL Top (https://forums.alliedmods.net/showthread.php?t=148791)

maza51 01-29-2011 06:49

SQL Top
 
Hello. I'm trying to make the top 10 players' statistics.
And when I take the information to the players:
PHP Code:

Format(querysizeof(query), "SELECT * FROM 'Players' WHERE map ='%s'"currentMap); 

Then I want to write all of the chat:
PHP Code:

        decl String:Toptime[30];
        
decl String:Topname[30];
        
        
SQL_FetchString(hndl1Topnamesizeof(Topname));
        
SQL_FetchString(hndl2Toptimesizeof(Toptime));
        
        
PrintToChatAll("\x05%s %s"ToptimeTopname); 

And I wrote in the chat for all players, without sorting. How to sort them in descending order?

Silvers 01-29-2011 06:52

Re: SQL Top
 
http://dev.mysql.com/doc/refman/5.0/...imization.html

maza51 01-29-2011 07:19

Re: SQL Top
 
PHP Code:

Format(querysizeof(query), "SELECT * FROM 'Players' ORDER BY time WHERE map ='%s'"currentMap); 

so?

Silvers 01-29-2011 07:30

Re: SQL Top
 
Yeah, try it.

maza51 01-29-2011 07:38

Re: SQL Top
 
Thank you. Work.

Another question.
How to check if the player is already in the database or not?

Leonardo 01-29-2011 07:48

Re: SQL Top
 
Quote:

Originally Posted by maza51 (Post 1402183)
PHP Code:

Format(querysizeof(query), "SELECT * FROM 'Players' ORDER BY time WHERE map ='%s'"currentMap); 


PHP Code:

"SELECT * FROM `Players` WHERE `map` ='%s' ORDER BY `time` LIMIT 0, 10" 

Quote:

Originally Posted by maza51 (Post 1402194)
How to check if the player is already in the database or not?

if SELECT query return 0 rows, so player isn't in DB

maza51 01-29-2011 08:22

Re: SQL Top
 
A sample can be?

maza51 01-29-2011 13:31

Re: SQL Top
 
Thanks Leonardo. Everything turned out =)

maza51 02-04-2011 13:40

Re: SQL Top
 
I did statistics on the point.
http://i16.fastpic.ru/big/2011/0204/...a3e1552310.jpg

How to make rank? To specify which positions are occupied by players.

Leonardo 02-04-2011 18:07

Re: SQL Top
 
is it top10 ?
PHP Code:

new i=1;
while(
SQL_FetchRow(sQuery))
{
      ...
      
PrintToChat(iClient"#%i %s with %i pts"i++, sPlayerNameiPlayerPoints)




All times are GMT -4. The time now is 04:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.