Raised This Month: $ Target: $400
 0% 

[Solved] Sorting Arrays


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 01-09-2016 , 10:31   Re: [Help] Sorting Arrays
Reply With Quote #6

Try :
PHP Code:
#include <amxmodx>

new g_score[33]

public 
plugin_init()
{
    
register_plugin("RoundEnd Score" "1.0" "siriusmd99" )
    
register_logevent("Round_End_Score"2"1=Round_End")
    
register_event("DeathMsg""sDeathMsg""a")
}

public 
client_connect(id) {g_score[id] = 0;}
public 
client_disconnect(id) {g_score[id] = 0;}

public 
sDeathMsg()
{
    new 
Killer read_data(1);
    new 
Victim read_data(2);
    if(
Killer != Victim)
        
g_score[Killer]++
}    

public 
Round_End_Score(){
    
    new 
sName[32], sBuffer[1024]
    new 
iLen
    
new scoretemp
    
new bool:ismax
    
    iLen 
+= formatex(sBuffer[iLen], charsmax(sBuffer) - iLen"Top Players Score:^n")
    
    while(!
is_empty())
    {
        for(new 
1sizeof(g_score); i++)
        {   
            
score g_score[i]
            
ismax true
            
for(new 1sizeof(g_score); j++)
            {    
                
temp g_score[j]
                if(
score<temp)
                {
                    
ismax false
                    
break
                }  
            }
            if(
ismax)
            {
                if(
is_user_connected(i) && score 0)
                {
                    
get_user_name(isName31)
                    
iLen += formatex(sBuffer[iLen], charsmax(sBuffer) - iLen"%s - %d^n"sNamescore)
                }
                
g_score[i]=0
            
}
        }            
    }
    
set_hudmessage(2552552550.020.2406.010.0__, -1)
    
show_hudmessage(0sBuffer)    
}


bool:is_empty()
{
for(new 
1sizeof(g_score); n++)
    if(
g_score[n])
        return 
false;    
    
return 
true;

I didn't sort array , just displayed live the score of players.

Last edited by siriusmd99; 01-09-2016 at 10:45.
siriusmd99 is offline
 



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 09:25.


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