Raised This Month: $ Target: $400
 0% 

Problem from SQL to MOTD


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
msbeden
Member
Join Date: Jan 2020
Location: Turkey, Eskisehir
Old 01-28-2020 , 02:50   Problem from SQL to MOTD
Reply With Quote #1

Hello. I pull data from SQL. I managed to print. But the lines are missing. I cannot change the "1023-iLen" section in the while loop. This time the plug-in is broken. Can you help me?

Caps:



My codes:

Code:
/*
    * This plugin has been written to the "OciXCrom's Rank System" plugin than by msbeden.
	* Required: OciXCrom's Rank System
    * Download: https://forums.alliedmods.net/showthread.php?t=308540
*/

#include <amxmodx>  
#include <amxmisc>  
#include <sqlx>  

#define PLUGIN "Top15 OciXCrom's Rank"  
#define VERSION "1.0"  
#define AUTHOR "msbeden"  

#define host "127.0.0.1"  
#define user "root"  
#define pass ""  
#define db "amx"  
#define MAX_BUFFER_LENGTH       4095

new Handle:sql, g_query[512]

public plugin_init()   
{  
    register_plugin(PLUGIN, VERSION, AUTHOR );  
    register_clcmd("say", "handle_say");    
}  

public plugin_cfg()
{  
    sql = SQL_MakeDbTuple(host, user, pass, db)
}  

public handle_say(id)   
{  
    static said[12]  
    read_argv(1, said, 11)  
    
    if(equal(said,"/top15") || equal(said,"!top15") || equal(said,".top15") || equal(said,"top15")) {  
        new data[1];data[0]=id  
        
        formatex(g_query,511,"SELECT Player, XP, Level FROM HGRutbe ORDER BY XP DESC LIMIT 15")  
        SQL_ThreadQuery(sql,"top15rank",g_query,data,1)  
    }  
    return PLUGIN_CONTINUE;  
}

public plugin_end()
{  
    SQL_FreeHandle(sql)  
}

public top15rank(FailState, Handle:Query, Error[], Errcode,Data[], DataSize)
{  
    new motd[1024];
    new iMax = 1; 
	new iLen = 0;

	if (iMax > 10)
		iMax = 10
	new lNick[40], lRanks[40], lXps[40], lAcc[40]
	format(lNick, 25, "Nick")
	format(lRanks, 25, "Rank")
	format(lXps, 25, "XP")

	ucfirst(lAcc)

	iLen = format( motd, MAX_BUFFER_LENGTH,
                  "<head><META http-equiv=Content-Type content='text/html ;charset=UTF-8'></head><style>body{background:#191818;background-image: url(^"http://i.hizliresim.com/d59r4p.jpg^");margin:5pt;padding:2pt;font-family:Tahoma;color:#ccc}.A{background-color:#262626;opacity:0.6;filter:alpha(opacity=60);}.B{background-color:#0b0b0b;opacity:0.6;filter:alpha(opacity=60);}td{font-size:15px}</style><center><table width=700>" )
	iLen += format( motd[iLen], MAX_BUFFER_LENGTH - iLen,
                  "<tr><td><br/> <td></tr><tr><td><br/> <b><td></tr><tr><td>%s<td>%s<td>%s<td>%s</b>",
                  "#", lNick, lRanks, lXps)

    static name[32];
    new point, line;

    while(SQL_MoreResults(Query)){  
        line++
        
        SQL_ReadResult(Query,0,name, 32)
        point = SQL_ReadResult(Query,1)
    
        iLen += format(motd[iLen], 1023-iLen,"<tr><td>%d <td>%s <td>%s <td>%i ^n", line, name, levelTranslate(point), point, point == 1 ? "" : "") 
        SQL_NextRow(Query)
    }

    copy(motd[iLen],MAX_BUFFER_LENGTH - iLen,"</table></center>");
    show_motd(0, motd,"Rank top15")
}  

public query(FailState, Handle:Query, Error[], Errcode)
{  
    
}

public levelTranslate(point)
{
    static name[300];
    if(point >= 1075000) {
        name = "Maresal";
    } else if(point >= 525000) {
        name = "GenelKurmay Baskani";
    } else if(point >= 525000) {
        name = "GenelKurmay";
    } else if(point >= 422500) {
        name = "Orgeneral";
    } else if(point >= 270000) {
        name = "Korgeneral";
    } else if(point >= 167500) {
        name = "Tumgeneral";
    } else if(point >= 125000) {
        name = "Tuggeneral";
    } else if(point >= 100000) {
        name = "Albay";
    } else if(point >= 87500) {
        name = "Yarbay";
    } else if(point >= 50000) {
        name = "Binbasi";
    } else if(point >= 36250) {
        name = "Yuzbasi";
    } else if(point >= 25000) {
        name = "Ustegmen";
    } else if(point >= 15000) {
        name = "Tegmen";
    } else if(point >= 7500) {
        name = "Astegmen";
    } else if(point >= 4000) {
        name = "Astsubay";
    } else if(point >= 2500) {
        name = "Uzman";
    } else if(point >= 500) {
        name = "Cavus";
    } else if(point >= 0) {
        name = "Onbasi";
    } else {
        name = "error";
    }

    return name;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Last edited by msbeden; 01-28-2020 at 07:49.
msbeden 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 02:53.


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