Junior Member
Join Date: Dec 2014
Location: India
|
12-17-2014
, 21:30
[Help] top15 fvault
|
#1
|
I have got the code to show fvault top 10 players, i want the plugin to show top 15 players, changes done in the code :-
PHP Code:
#define MAX_BUFFER_LENGTH 3047
new g_Top15Motd[ MAX_BUFFER_LENGTH + 1 ]
enum _:FvaultData {
gSteamID[ 450 ],
gPointsData[ 750 ]
}
public MakeTop15( id )
{
new iLen
iLen = formatex( g_Top15Motd, MAX_BUFFER_LENGTH,
"<html><head><meta charset=^"UTF-8^">\
<body bgcolor=#242424 style=^"color:#FFF^">\
<table width=100%% cellspacing=0 border=0>\
<tr align=center bgcolor=#444444>\
<th width=4%%>#\
<th width=30%% align=left>Player\
<th width=8%%>Kills\
<th width=8%%>Deaths\
<th width=8%%>HS\
<th width=8%%>Knife\
<th width=8%%>Grenade\
<th width=8%%>Bombs\
<th width=8%%>Defuses" )
new Array:aKey = ArrayCreate( 450 )
new Array:aData = ArrayCreate( 750 )
new Array:aAll = ArrayCreate( FvaultData )
fvault_load( g_VaultData, aKey, aData )
new iArraySize = ArraySize( aKey )
new Data[ FvaultData ]
new i
for( i = 0; i < iArraySize; i++ )
{
ArrayGetString( aKey, i, Data[ gSteamID ], sizeof Data[ gSteamID ] - 1 )
ArrayGetString( aData, i, Data[ gPointsData ], sizeof Data[ gPointsData ] - 1 )
ArrayPushArray( aAll, Data )
}
ArraySort( aAll, "SortData" )
new szKills[ 10 ];
new szDeaths[ 10 ];
new szHeadShots[ 10 ];
new szKnifeKills[ 10 ];
new szKnifeDeaths[ 10 ];
new szGrenadeKills[ 10 ];
new szGrenadeDeaths[ 10 ];
new szBombPlanted[ 10 ];
new szBombExplosions[ 10 ];
new szBombDefusions[ 10 ];
new szBombDefused[ 10 ];
new szWonRounds[ 10 ];
new szShots[ 10 ];
new szDamage[ 10 ];
new szTeamKills[ 10 ];
new szBestKills[ 10 ];
new szBestDeaths[ 10 ];
new szName[ 32 ]
new iSize = clamp( iArraySize, 0, 15 )
new j
for( j = 0; j < iSize; j++ )
{
ArrayGetArray( aAll, j, Data )
fvault_get_data( g_VaultNames, Data[ gSteamID ], szName, charsmax( szName ) )
replace_all( szName, charsmax( szName ), "<", "[" )
replace_all( szName, charsmax( szName ), ">", "]" )
parse(Data[ gPointsData ],
szKills, sizeof szKills,
szDeaths, sizeof szDeaths,
szHeadShots, sizeof szHeadShots,
szKnifeKills, sizeof szKnifeKills,
szKnifeDeaths, sizeof szKnifeDeaths,
szGrenadeKills, sizeof szGrenadeKills,
szGrenadeDeaths, sizeof szGrenadeDeaths,
szBombPlanted, sizeof szBombPlanted,
szBombExplosions, sizeof szBombExplosions,
szBombDefusions, sizeof szBombDefusions,
szBombDefused, sizeof szBombDefused,
szWonRounds, sizeof szWonRounds,
szShots, sizeof szShots,
szDamage, sizeof szDamage,
szTeamKills, sizeof szTeamKills,
szBestKills, sizeof szBestKills,
szBestDeaths, sizeof szBestDeaths);
if(equal(g_iAuthData[ id ], Data[ gSteamID ]))
{
iLen += formatex( g_Top15Motd[ iLen ], MAX_BUFFER_LENGTH - iLen, "<tr align=center bgcolor=#333333>" )
}
else
{
iLen += formatex( g_Top15Motd[ iLen ], MAX_BUFFER_LENGTH - iLen, "<tr align=center>" )
}
iLen += formatex( g_Top15Motd[ iLen ], MAX_BUFFER_LENGTH - iLen, "<td>%i<td align=left>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s<td>%s", j + 1, szName, szKills, szDeaths, szHeadShots, szKnifeKills, szGrenadeKills, szBombExplosions, szBombDefused )
}
iLen += formatex( g_Top15Motd[ iLen ], MAX_BUFFER_LENGTH - iLen, "</table><center>The code added to check ***</center></body></html>" )
ArrayDestroy( aKey )
ArrayDestroy( aData )
ArrayDestroy( aAll )
}
public SortData( Array:aArray, iItem1, iItem2, iData[ ], iDataSize )
{
new Data1[ FvaultData ]
new Data2[ FvaultData ]
ArrayGetArray( aArray, iItem1, Data1 )
ArrayGetArray( aArray, iItem2, Data2 )
new szPoints_1[ 7 ]
parse( Data1[ gPointsData ], szPoints_1, charsmax( szPoints_1 ) )
new szPoints_2[ 7 ]
parse( Data2[ gPointsData ], szPoints_2, charsmax( szPoints_2 ) )
new iCount1 = str_to_num( szPoints_1 )
new iCount2 = str_to_num( szPoints_2 )
return ( iCount1 > iCount2 ) ? -1 : ( ( iCount1 < iCount2 ) ? 1 : 0 )
}
The result i got :-
http://www.mediafire.com/convkey/afb....jpg?size_id=6
I have added the following html code to check if array size is enough !
PHP Code:
iLen += formatex( g_Top15Motd[ iLen ], MAX_BUFFER_LENGTH - iLen, "</table><center>The code added to check ***</center></body></html>" )
It show's the top 12 players perfectly, but not 13 ,14 and 15
|
|