Highest score!
#6

Quote:
Originally Posted by Finn
Посмотреть сообщение
Have you even tested that BubbleSort function?

You have to be lucky to have an array which actually gets sorted by using that function.
The function was tested and working.


#You can replace:
pawn Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/rankScore", true))
    {
        static
            Scores[MAX_PLAYERS],
            String[128],
            Nome[24],
            IntVar,
        ;
           
        for(IntVar = 0; IntVar != MAX_PLAYERS; ++IntVar) Scores[IntVar] = GetPlayerScore(IntVar);
       
        BubbleSort(Scores, sizeof(Scores));
       
        for(IntVar = 0; IntVar < 10; ++i)
        {  
            GetPlayerName(IntVar, Nome, 24);
            format(String, sizeof(String),"%i є  Name: %s Score: %s", IntVar+1, Nome, Scores[IntVar]);
            SendClientMessage(playerid, -1, String);
        }
        return 1;
    }
    return 0;
}


static stock BubbleSort(v[], size)
{
    #if !defined swap
        #define swap(%0,%1)  (%0 ^= %1, %1 ^= %0, %0 ^= %1)
    #endif
    for(new i = 1; i != size; ++i)
    {
        for(new q = 0; (q != size - i); ++q)if(v[i] > v[q]) swap(v[q],v[i]);
    }
}
Reply


Messages In This Thread
Highest score! - by Zhoom - 03.03.2012, 04:55
Re: Highest score! - by DarkScripter - 03.03.2012, 05:13
Re: Highest score! - by Finn - 03.03.2012, 05:31
Re: Highest score! - by -Prodigy- - 03.03.2012, 05:31
Re: Highest score! - by Zhoom - 03.03.2012, 05:32
Re: Highest score! - by DarkScripter - 03.03.2012, 05:36
Re: Highest score! - by Zhoom - 03.03.2012, 05:57
Re: Highest score! - by Finn - 03.03.2012, 06:02
Re: Highest score! - by DarkScripter - 03.03.2012, 06:31

Forum Jump:


Users browsing this thread: 1 Guest(s)