SA-MP Forums Archive
Get the max gang score - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get the max gang score (/showthread.php?tid=132053)



Get the max gang score - Headshot1108 - 06.03.2010

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);
    }
     }
     }



Re: Get the max gang score - dice7 - 06.03.2010

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);
}



Re: Get the max gang score - Headshot1108 - 06.03.2010

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!


Re: Get the max gang score - ipsBruno - 17.04.2010

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

Sorry I Am Bas English I am brasilian