AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why does this top10 not show top20? (https://forums.alliedmods.net/showthread.php?t=309772)

blood2k 08-06-2018 15:52

Why does this top10 not show top20?
 
Code:

// Get and format top 15.
format_top15( id, sBuffer[MAX_BUFFER_LENGTH + 1])
{
        new iMax = get_statsnum()
        new izStats[8], izBody[8]
        new iLen = 0

        if (iMax > 10)
                iMax = 10

        new istate[2]

        new top_name[64]
        format ( top_name, sizeof ( top_name ) - 1, "%L", id, "HTML_PLAYER_TOP" )
        iLen = format ( sBuffer, MAX_BUFFER_LENGTH, "%L%L", id, "HTML_TOP_BODY", top_name, id, "HTML_TOP_HEADER" )

        for (new i = 0; i < iMax && MAX_BUFFER_LENGTH - iLen > 0; i++)
        {
                if (equali(istate, "a"))
                        copy(istate, sizeof(istate)-1, "b")
                else
                        copy(istate, sizeof(istate)-1, "a")
                get_stats(i, izStats, izBody, t_sName, MAX_NAME_LENGTH)
                replace_all(t_sName, MAX_NAME_LENGTH, "<", "[")
                replace_all(t_sName, MAX_NAME_LENGTH, ">", "]")
                iLen += format(sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L", id, "HTML_TOP_TABLE", istate, i+1, t_sName, izStats[STATS_KILLS],
                                                izStats[STATS_DEATHS], izStats[STATS_HITS], izStats[STATS_SHOTS], izStats[STATS_HS], effec(izStats), accuracy(izStats))
        }
        iLen += format ( sBuffer[iLen], MAX_BUFFER_LENGTH - iLen, "%L", id, "HTML_CLOSE" )
}



I changed the 2 iMax that say 10, to 20... but it then shows 13 players and 13th has no stats... how do I get this to show 20? :/

Bugsy 08-06-2018 21:01

Re: Why does this top10 not show top20?
 
sBuffer[] may be too small

blood2k 08-06-2018 22:01

Re: Why does this top10 not show top20?
 
What's a good value?

Black Rose 08-07-2018 17:10

Re: Why does this top10 not show top20?
 
Quote:

Originally Posted by blood2k (Post 2608761)
What's a good value?

To make it easy, double whatever you had previously.
You do however have a limit in the MOTD of 1536 characters which you probably will hit. In order to work around that you'll have to print everything to a local file and link the MOTD to the file instead of supplying it a string.

I think it's as easy as this, haven't tested it thought. :)
Code:
show_motd(id, sBuffer);
->
Code:
new hFile = fopen("top20.htm", "w"); fputs(hFile, sBuffer); fclose(hFile); show_motd(id, "top20.htm");

sb123 08-08-2018 06:30

Re: Why does this top10 not show top20?
 
1 Attachment(s)
Build a "HTM" folder under the "cstrike" folder, put "top15.htm" in this "HTM" folder, open "top15.htm" with Notepad or other text editing software, and change the address behind the URL in the inside to the URL address of someone who can access the "top15_result.htm" file. (Note: "top15_result.htm" files are generated by the plug-in)

Using this plug-in's TOP15, you need to open the Web service in your server and use the "HTM" folder as the root address of your Web server or a virtual directory in it. The contents of Web services are not discussed here. Here is no introduction. Please check the data yourself. Build a "HTM" folder under the "cstrike" folder, put "top15.htm" in this "HTM" folder, open "top15.htm" with Notepad or other text editing software, and change the address behind the URL in the inside to the URL address of someone who can access the "top15_result.htm" file. (Note: "top15_result.htm" files are generated by the plug-in)

Using this plug-in's TOP15, you need to open the Web service in your server and use the "HTM" folder as the root address of your Web server or a virtual directory in it. The contents of Web services are not discussed here. Here is no introduction. Please check the data yourself.

fysiks 08-08-2018 12:42

Re: Why does this top10 not show top20?
 
Quote:

Originally Posted by Black Rose (Post 2608995)
To make it easy, double whatever you had previously.
You do however have a limit in the MOTD of 1536 characters which you probably will hit. In order to work around that you'll have to print everything to a local file and link the MOTD to the file instead of supplying it a string.

I think it's as easy as this, haven't tested it thought. :)
Code:
show_motd(id, sBuffer);
->
Code:
new hFile = fopen("top20.htm", "w"); fputs(hFile, sBuffer); fclose(hFile); show_motd(id, "top20.htm");

IIRC, the limit is still there for displaying a file. It has to do with transmitting to the player. So, the only way to bypass that limit is to host the content on a website.

Black Rose 08-08-2018 13:17

Re: Why does this top10 not show top20?
 
Quote:

Originally Posted by fysiks (Post 2609128)
IIRC, the limit is still there for displaying a file. It has to do with transmitting to the player. So, the only way to bypass that limit is to host the content on a website.

Good to know, thanks.


All times are GMT -4. The time now is 12:39.

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