Raised This Month: $51 Target: $400
 12% 

rank? sorting the stats


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-23-2011 , 22:50   rank? sorting the stats
Reply With Quote #1

I'm working on a plug-in and am storing my information of each player in keyvalues like this \/ and i need to know how to go through all of these steam ids and sort them in order by there statpoints

Code:
"MyFile"
{
	"STEAM_0:0:7"
	{
		"statpoints"	"758396"
		"kills"		"6474759473"
		"deaths"	"73956395"
	}
}
Flow Low is offline
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 04-24-2011 , 13:20   Re: rank? sorting the stats
Reply With Quote #2

It would probably be best to use a database and using "ORDER BY". Otherwise just loop though all the keyvalues x times and get the next highest one each time.
noodleboy347 is offline
Master53
Veteran Member
Join Date: Dec 2009
Old 04-24-2011 , 17:45   Re: rank? sorting the stats
Reply With Quote #3

wouldn't SQL based saving be better than KV?
__________________
Master(d)



Master53 is offline
Flow Low
Junior Member
Join Date: Apr 2011
Old 04-25-2011 , 07:31   Re: rank? sorting the stats
Reply With Quote #4

Probably, looks like im going to have to learn sql
Flow Low is offline
Master53
Veteran Member
Join Date: Dec 2009
Old 04-25-2011 , 08:48   Re: rank? sorting the stats
Reply With Quote #5

i can give you an example of a your ranking mod.


PHP Code:
    //Handle:
    
new Handle:query SQL_Query(hSQLbuffer);

    
//Sql String:
    
Format(buffersizeof(buffer), "SELECT * FROM `PlayerRank` ORDER BY Points DESC LIMIT 10;");

    
//Handle:
    
query SQL_Query(hSQLbuffer);

    
//Declare:
    
new 0;

    
//Declare:
    
decl TopSteamId[10], String:TopName[10][32];

    
//Not Player:
    
while (SQL_FetchRow(query))
    {

        
//Database Field Loading Intiger:
        
TopSteamId[i] = SQL_FetchInt(query0);

        
//Database Field Loading String:
        
SQL_FetchString(query1TopName[i], 32);

        
i++;
    }

    
//Close:
    
CloseHandle(query); 
will fetch database field from a clients steamid.

you can also use a SQL_TQuery but i like to use SQL_Query to fetch database data.
PHP Code:

    
//Declare:
    
decl String:buffer[256];

    
//Format:
    
Format(buffersizeof(buffer), "SELECT * FROM `PlayerRank` ORDER BY POINTS DESC LIMIT 0,10");

    
//Handle:
    
SQL_TQuery(dbT_ShowTOP1bufferGetClientUserId(Client));


public 
T_ShowTOP1(Handle:ownerHandle:hndl, const String:error[], any:data)
{

    
//Declare:
    
decl client;

    
/* Make sure the client didn't disconnect while the thread was running */
    
if((client GetClientOfUserId(data)) == 0)
    {

        
//Return:
        
return;
    }

    if (
hndl == INVALID_HANDLE)
    {

        
//Log Error:
        
LogError("Query failed! %s"error);
    }
    else
    {

        
//Declare:
        
decl TopSteamId[10], String:TopName[10][32];

        
//Declare:
        
new 1;

        
//Not Player:
        
while (SQL_FetchRow(hndl))
        {

            
//Database Field Loading Intiger:
            
TopSteamId[i] = SQL_FetchInt(query0);

            
//Database Field Loading String:
            
SQL_FetchString(query1TopName[i], 32);

            
i++;
        }

        
//Return:
        
return
    }

    
//Return:
    
return

is an example of using SQL_TQuery.
__________________
Master(d)




Last edited by Master53; 04-25-2011 at 08:56.
Master53 is offline
Samantha
SourceMod Donor
Join Date: Feb 2010
Location: Madagascar
Old 04-25-2011 , 11:39   Re: rank? sorting the stats
Reply With Quote #6

Forget everything that was said and read this: http://wiki.alliedmods.net/SQL_%28So...d_Scripting%29

If you've never used mysql before read this http://www.w3schools.com/sql/default.asp
__________________
"I give sopport and knolage in making extractions"
"MASTER(D) - dun0: are you mocing me?" -Master the grate

Plugins
Godmode Until Attack | No Block Team Filter
Extensions
Rcon Hooks
Samantha is offline
Dravu
Senior Member
Join Date: May 2010
Old 04-25-2011 , 16:56   Re: rank? sorting the stats
Reply With Quote #7

If you use SQL, please use the threaded version for Sourcemod.
Dravu is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:36.


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