Get the max gang score
#1

i have a problem.
I like to get the max gang score from all gangs.

but dont work?
In game does not come the right gang with the max score, seperate come the first gang.

my code:
pawn Код:
if(strcmp("/toplist", cmd, true) == 0)
    {
    for(new i = 0; i < MAX_GANGS; i++)
    {
    if(GangInfo[i][gangScore] > i)
    {
    format(string, sizeof(string), "%d", GangInfo[i][gangScore]);
    SendClientMessageToAll(rot,string);
    }
     }
     }
Reply
#2

This will just find the largest score, like you're trying to do
pawn Код:
if(strcmp("/toplist", cmd, true) == 0)
{
    new max = GangInfo[0][gangScore];
    for(new i = 0; i < MAX_GANGS; i++)
    {
        if(GangInfo[i][gangScore] > max)
        {
            max = GangInfo[i][gangScore];
        }
    }
    format(string, sizeof(string), "%d", max);
    SendClientMessageToAll(rot,string);
}
And this will give you the index of the gang with the highest score (maxi)
pawn Код:
if(strcmp("/toplist", cmd, true) == 0)
{
    new max = GangInfo[0][gangScore];
    new maxi;
    for(new i = 0; i < MAX_GANGS; i++)
    {
        if(GangInfo[i][gangScore] > max)
        {
            max = GangInfo[i][gangScore];
            maxi = i;
        }
    }
    format(string, sizeof(string), "%d", GangInfo[maxi][gangScore]);
    SendClientMessageToAll(rot,string);
}
Reply
#3

thanks it work!
but how i can make the 2nd and 3rd place?

i make as test the 2nd place, but doesnt work:

pawn Код:
if(strcmp("/toplist", cmd, true) == 0)
    {
        new max1 = GangInfo[0][gangScore];
        new maxi;
        for(new i = 0; i < MAX_GANGS; i++)
        {
            if(GangInfo[i][gangScore] > max1)
            {
                max1 = GangInfo[i][gangScore];
                maxi = i;
            }
        }
        new max2 = GangInfo[0][gangScore];
        new maxi2;
        for(new i = 0; i < MAX_GANGS; i++)
        {
            if(max1 > GangInfo[i][gangScore])
            {
                max2 = GangInfo[i][gangScore];
                maxi2 = i;
            }
        }
        format(string, sizeof(string), "1. Gang: %s - %d Score", GangInfo[maxi][gangNames], GangInfo[maxi][gangScore]);
        SendClientMessageToAll(HELLBLAU,string);
        format(string, sizeof(string), "2. Gang: %s - %d Score", GangInfo[maxi2][gangNames], GangInfo[maxi2][gangScore]);
        SendClientMessageToAll(HELLBLAU,string);
        return 1;
    }


// EDIT: Fixed!
Reply
#4

Could you pass me the "# define" the code for me by the GM?

Sorry I Am Bas English I am brasilian
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)