AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved]2D array & compare floats (https://forums.alliedmods.net/showthread.php?t=88648)

Dr.G 03-27-2009 18:46

[solved]2D array & compare floats
 
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_killerid )
{
if(!
get_pcvar_num(p_on))
return 
PLUGIN_HANDLED
 
new players[32], indexcountnumi
get_players
playersnum )
 
for( ; 
numi++ )
{
index players];
 
g_Sortcount ][ ] = index
g_Sort
count ][ ] = g_noscope_counterindex ]
 
count++
}
 
SortCustom2Dg_Sortcount"compare_kills" )
 
new 
Motd1024 ], Len
 
Len 
formatMotdcharsmaxMotd ),"<body bgcolor=#000000><font color=#98f5ff><pre>" )
Len += formatMotdLen ], charsmaxMotd ) - Len,"%s %-22.22s %3s^n""#""Name""Unscoped Kills" )
 
 
new 
clampcount0get_pcvar_num(top_x) )
 
new 
name32 ], playerj
 
for( ; bj++ )
{
player g_Sort][ ]
 
get_user_nameplayernamesizeof name )
 
Len += formatMotdLen ], charsmaxMotd )-Len,"%d %-22.22s %d^n"j+1nameg_Sort][ ] )
}
Len += formatMotdLen ], charsmaxMotd )-Len,"</body></font></pre>" )
 
show_motdidMotdPLUGIN )
 
return 
PLUGIN_CONTINUE


the compare func:

PHP Code:

////////////////////////////////////////////////////////////////////////////////////////////////////
public compare_killselem1[ ], elem2[ ] )
{
if( 
elem1] > elem2] )
return -
1;
else if( 
elem1] < elem2] )
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 :wink:

Exolent[jNr] 03-27-2009 19:00

Re: 2D array & compare floats
 
Code:
enum _:SortData {     sd_index,     Float:sd_noscope_counter }; // ... new g_Sort[32][SortData]; // ... g_Sort[count][sd_index] = index; g_Sort[count][sd_noscope_counter] = g_noscope_counter[index];

Dr.G 03-27-2009 20:44

Re: 2D array & compare floats
 
thanks but still gives me that error, check the attachment.

look at line 21, 25 - 31 and the function from line 286 to 332

Exolent[jNr] 03-27-2009 20:55

Re: 2D array & compare floats
 
1 Attachment(s)
Try this:

Dr.G 03-27-2009 21:09

Re: 2D array & compare floats
 
awesome thanks alot!


All times are GMT -4. The time now is 08:51.

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