Highest score!
#7

Quote:
Originally Posted by -Prodigy-
Посмотреть сообщение
This will get the player with the highest score:
pawn Код:
new
    iHighest;

for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(GetPlayerScore(i) > GetPlayerScore(iHighest)) iHighest = i;
    }
}

// The variable: "iHighest" now contains the player id holding the highest score.
tested, doesnt work.




Quote:
Originally Posted by DarkScripter
Посмотреть сообщение
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]);
    }
}
i got 2 errors:
Код:
error 001: expected token: "-identifier-", but found ";"
error 017: undefined symbol "i"

well can you make it become SetTimer and forward please.. it is easier for me to look up, thanks.
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)