Raised This Month: $ Target: $400
 0% 

Rank System using SQLx


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-09-2010 , 20:38   Rank System using SQLx
Reply With Quote #1

I really don't know to how do it, but i founded this code:

PHP Code:
public clcmd_rank(id)
{
    if (
GET_FL(idFLAG_LOADING))
        return 
PLUGIN_HANDLED;
    
    if (
GET_CASE(id) != CASE_INGAME)
        return 
PLUGIN_HANDLED;
    
    new 
consult[1024]
    
    new 
data[INFO_LEN]
    
    
get_packet(iddata)
    
    
formatex(consultcharsmax(consult), "SELECT *,(SELECT COUNT(*) FROM `%s`) AS `total` FROM (SELECT *, (@rownum := @rownum + 1) AS `rank` \
    FROM `%s`, (SELECT @rownum := 0) AS `R` ORDER BY d1 DESC, d2 DESC) AS `newtable` WHERE `pj` = '%s';"
_TABLE_TABLEesc_character[id])
    
    
loading(id1)
    
    
SQL_ThreadQuery(tuple"query_rank"consultdataINFO_LEN)
    
    return 
PLUGIN_CONTINUE;
}

public 
query_rank(failstateHandle:queryerror[], errcodedata[], datasize)
{
    
// lots of error checking
    
if (!check_error(data[0], "query_rank"failstateerrcodeerror))
        return 
PLUGIN_CONTINUE;
    
    if (!
get_unique(data))
        return 
PLUGIN_CONTINUE;

    new 
id data[0]
    
    
loading(id)
    
    new 
irank SQL_FieldNameToNum(query"rank")
    new 
itotal SQL_FieldNameToNum(query"total")
    
    new 
rank SQL_ReadResult(queryirank)
    new 
total SQL_ReadResult(queryitotal)
    
    
client_print_color(idBlue"%s %L"cprefixid"C_RANK"ranktotal)
    
    return 
PLUGIN_CONTINUE;

Theres 2 problems:
  1. I don't understand too much things from that code
  2. How to do without SQL_ThreadQuery?
And i founded too a Top15 code:

PHP Code:
public clcmd_top10(id)
{
    if (
GET_FL(idFLAG_LOADING)) return PLUGIN_HANDLED;
    
    new 
consult[256]
    
    new 
data[INFO_LEN]
    
    
get_packet(iddata)
    
    
formatex(consultcharsmax(consult), "SELECT * FROM `%s` ORDER BY d1 DESC, d2 DESC LIMIT 10"_TABLE);
    
    
loading(id1)
    
    
SQL_ThreadQuery(tuple"query_top10"consultdataINFO_LEN)
    
    return 
PLUGIN_CONTINUE;
}

public 
query_top10(failstateHandle:queryerror[], errcodedata[], datasize)
{
    
// lots of error checking
    
if (!check_error(data[0], "query_top10"failstateerrcodeerror))
        return 
PLUGIN_CONTINUE;
    
    if (!
get_unique(data))
        return 
PLUGIN_CONTINUE;

    new 
id data[0]
    
    
loading(id)
    
    new 
name[64], buffer[2048], len0
    
    len 
+= formatex(buffer[len], charsmax(buffer) - len"<meta charset=UTF-8><style>body{color:#FFFFFF;background-color:black;margin-top:5;font-family:arial}table{border-collapse:separate;border-spacing:1px;text-align:left;}")

    
len += formatex(buffer[len], charsmax(buffer) - len"td{font-size:15px;}</style>")

//    len += formatex(buffer[len], charsmax(buffer) - len, "<center><b><font size=6>ZP Top 10</b><table border=1 width=700>")

    #if defined USE_CROSSGAMING
    
len += formatex(buffer[len], charsmax(buffer) - len"<center><img src=^"http://www.killer-instinct.com.ar/imageneszp/top10.bmp^"></img><table border=1 width=700>")
    #else
    
len += formatex(buffer[len], charsmax(buffer) - len"<center><img src=^"http://www.killer-instinct.com.ar/imageneszp/top10mz.bmp^"></img><table border=1 width=700>")
    #endif
    
len += formatex(buffer[len], charsmax(buffer) - len"%s","<br><tr bgcolor=#0000FF><td>#<td>Nick<td>Level<td>AP<td>Z matados<td>H matados<td>H infectados<td>N matados<td>S matados</tr>")
    
    
    new 
ipj SQL_FieldNameToNum(query"pj")
    new 
ilevel SQL_FieldNameToNum(query"d0")
    new 
iap SQL_FieldNameToNum(query"d1")
    new 
izkill SQL_FieldNameToNum(query"d2")
    new 
ihkill SQL_FieldNameToNum(query"d3")
    new 
ihinfected SQL_FieldNameToNum(query"d6")
    new 
inkill SQL_FieldNameToNum(query"d4")
    new 
iskill SQL_FieldNameToNum(query"d5")
    
    while (
SQL_MoreResults(query))
    {
        
i++
        
        if (
!= 1)
            
len += formatex(buffer[len], charsmax(buffer) - len"<tr><td>%d"i)
        else
            
len += formatex(buffer[len], charsmax(buffer) - len"<tr bgcolor=#FF0000><td>%d"i)
        
        
SQL_ReadResult(queryipjnamecharsmax(name))
        
    
//    replace_all(name, charsmax(name), ">", "gt;")
        
replace_all(namecharsmax(name), "<""lt;")    
        
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%-22.22s"name)    
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryilevel))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryiap))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryizkill))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryihkill))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryihinfected))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryinkill))
        
len += formatex(buffer[len], charsmax(buffer) - len"<td>%d"SQL_ReadResult(queryiskill))

        
SQL_NextRow(query)
    }
    
    
len += formatex(buffer[len], charsmax(buffer) - len"</table></font>")
    
    
show_motd(idbuffer"ZP Top 10")
    
    return 
PLUGIN_CONTINUE

Same problems...

I want please if someone can do a correct example for me

For example, a money rank, data num 0 = 'account_name', data num 1 = 'money'

Sorry if i didn't expressed it well.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
 



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 03:38.


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