i made a no scope notifier for dod. All players top distances is saved to
PHP Code:
new Float:g_noscope_counter_dist[33]
now i need a function to compare these distances and show the top distances in a motd thats showen with a say cmd e.g. anakin_cstrike made this function in his zoomless plugin:
PHP Code:
////////////////////////////////////////////////////////////////////////////////////////////////////
// by anakin_cstrike...
public show_unscoped_top_killer( id )
{
if(!get_pcvar_num(p_on))
return PLUGIN_HANDLED
new players[32], index, count, num, i
get_players( players, num )
for( ; i < num; i++ )
{
index = players[ i ];
g_Sort[ count ][ 0 ] = index
g_Sort[ count ][ 1 ] = g_noscope_counter[ index ]
count++
}
SortCustom2D( g_Sort, count, "compare_kills" )
new Motd[ 1024 ], Len
Len = format( Motd, charsmax( Motd ),"<body bgcolor=#000000><font color=#98f5ff><pre>" )
Len += format( Motd[ Len ], charsmax( Motd ) - Len,"%s %-22.22s %3s^n", "#", "Name", "Unscoped Kills" )
new b = clamp( count, 0, get_pcvar_num(top_x) )
new name[ 32 ], player, j
for( ; j < b; j++ )
{
player = g_Sort[ j ][ 0 ]
get_user_name( player, name, sizeof name - 1 )
Len += format( Motd[ Len ], charsmax( Motd )-Len,"%d %-22.22s %d^n", j+1, name, g_Sort[ j ][ 1 ] )
}
Len += format( Motd[ Len ], charsmax( Motd )-Len,"</body></font></pre>" )
show_motd( id, Motd, PLUGIN )
return PLUGIN_CONTINUE
}
the compare func:
PHP Code:
////////////////////////////////////////////////////////////////////////////////////////////////////
public compare_kills( elem1[ ], elem2[ ] )
{
if( elem1[ 1 ] > elem2[ 1 ] )
return -1;
else if( elem1[ 1 ] < elem2[ 1 ] )
return 1;
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
and that works great for compareing numbers, gj btw. but how can i add a float to g_Sort[ count ][ 1 ] and compare them? if i say g_Sort[ count ][ 1 ] = g_noscope_counter_dist[ id ] that have a floating value, i get tag mistakes.
Maybe this isnt the way to do it, all suggestions or just a hint is very welcome
__________________