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

Run time error 3: stack error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeNq!
Senior Member
Join Date: Mar 2009
Old 01-06-2021 , 05:42   Run time error 3: stack error
Reply With Quote #1

Hello,

I have a problem. Due to the fact that the buffer is 9999, an error occurs. How do I correct this from get_statsnum () then?

Code:
public clcmd_csgo_top15( id )
{		
	new iStatsTotal = get_statsnum();
	new gTopSort[ 9999 ][ 2 ];
	
	new iStats[ 8 ];
	new iBodyHits[ 8 ];
	new szName[ MAX_NAME_LENGTH ];

	for ( new i = 0 ; i < iStatsTotal ; i++ )
	{
		get_stats( i, iStats, iBodyHits, szName, charsmax( szName ) );
        
		gTopSort[ i ][ 0 ] = i;
		gTopSort[ i ][ 1 ] = iStats[ 0 ];
	}
    
	SortCustom2D( gTopSort, iStatsTotal, "Sort_TOP15" );
	
	new szMotd[ MAX_MOTD_LENGTH ], iLen;
	
	iLen = formatex( szMotd, charsmax( szMotd ), "<head><meta charset=UTF-8>\
	<style>body{background: #000}table, th, td{border: 1px solid black;border-collapse: collapse;}</style></head>\
	<body><table width=100%% cellpadding=2 cellspacing=0 border=1>\
	<tr align=center style=color:#00c4ff><th width=20%%>#<th width=60%%>Player<th width=20%%>Kills</tr>");
		
	for( new x = 0; x < 15; x++ )
	{
		get_stats( gTopSort[ x ][ 0 ], iStats, iBodyHits, szName, charsmax( szName ) );
				
		iLen += formatex( szMotd[ iLen ], ( sizeof szMotd - 1 ) - iLen, "<tr align=center style=^"color:#fff^"><td>%d<td>%s<td>%s", x + 1, szName, gTopSort[ x ][ 1 ] );
	}
	
	iLen += formatex( szMotd[iLen], ( sizeof szMotd - 1 ) - iLen, "</body></font></pre>" );
	show_motd( id, szMotd, "TOP 15" );
}
BeNq! is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-06-2021 , 08:14   Re: Run time error 3: stack error
Reply With Quote #2

Code:
static gTopSort[ 9999 ][ 2 ];

Since everything is regulated by iStatsTotal you shouldn't have to clean it each cycle (static is more or less a global variable and retains it's value when execution is exiting the scope)
__________________
Black Rose is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-06-2021 , 20:28   Re: Run time error 3: stack error
Reply With Quote #3

You don't need to use an array that big, use instead the dynamic array system.

Also I don't think you need any sorting, show sort_TOP15
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-06-2021 at 20:31.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 23:31.


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