PAWNO crashes/lags
#2

I believe this happens due to lots of case statements(because it stops to crash for me when u comment some of them). I advise you to use binary search which is a very fast way to set rank especialy when you have a big number of ranks.

pawn Код:
static const Ranks[10] = {0, 400, 2000, 4000, 8000, 10000, 15000, 25000, 30000, 40000};
stock SetPlayerRank(playerid)
{
    new score = GetPlayerScore(playerid);
    new l, r, m;
    l = 0; r = sizeof(Ranks);
    while(r > l)
    {
        m = (r+l) >> 1;
        if(Ranks[m] <= score) l = m+1;
        else r = m;
    }
    PlayerRank[playerid] = l;
    return l;
}
Reply


Messages In This Thread
PAWNO crashes/lags - by LocMax - 04.02.2014, 15:32
Re: PAWNO crashes/lags - by Borg - 04.02.2014, 15:53
Re: PAWNO crashes/lags - by PowerPC603 - 04.02.2014, 16:35
Re: PAWNO crashes/lags - by LocMax - 04.02.2014, 16:45

Forum Jump:


Users browsing this thread: 2 Guest(s)