02.06.2016, 10:32
I was making a /top CMD, through which players can see the name of the player who got highest score/kills/spree in recent 12 hours.
But, somehow, bugs kept coming, and kept making a new logic, more effective each time, and I think I'm close enough, but a bug is still remaining.
Here's the code, I hope you guys can help me (p.s my first time requesting help on samp forums so take it easy )
But, somehow, bugs kept coming, and kept making a new logic, more effective each time, and I think I'm close enough, but a bug is still remaining.
Here's the code, I hope you guys can help me (p.s my first time requesting help on samp forums so take it easy )
PHP код:
if(killerid != INVALID_PLAYER_ID)
{
new PlayerScore[5], PlayerName[5][MAX_PLAYER_NAME];
for(new i=0; i < 5; i++)
{
if(!strcmp(TopScore[i][pPlayer], GetName(killerid)))
{
if(TopInfo[killerid][Score] > TopScore[i][pScore])
{
if(i != 4 && i != 0)
{
new k = i;
for(new j=k; j > -1; j--)
{
new l= j-1;
if(TopInfo[killerid][Score] > TopScore[l][pScore])
{
i = l;
PlayerScore[l] = TopScore[l][pScore];
PlayerName[l] = TopScore[l][pPlayer];
}
}
for(new j=k; j > -1; j--)
{
new l= j-1;
if(TopInfo[killerid][Score] > TopScore[l][pScore])
{
TopScore[l-1][pScore] = PlayerScore[l];
TopScore[l-1][pPlayer] = PlayerName[l];
}
}
}
TopScore[i][pScore] = TopInfo[killerid][Score];
TopScore[i][pPlayer] = GetName(killerid);
}
break;
}
else continue;
}
for(new y=0; y < 5; y++)
{
if(strcmp(TopScore[y][pPlayer], GetName(killerid)) && TopInfo[killerid][Score] > TopScore[y][pScore])
{
if(y != 4 && y != 0)
{
new k = y;
for(new j=k; j < 5; j++)
{
//new l= j+1;
PlayerScore[j] = TopScore[j][pScore];
PlayerName[j] = TopScore[j][pPlayer];
}
for(new j=k; j < 5; j++)
{
TopScore[j+1][pScore] = PlayerScore[j];
TopScore[j+1][pPlayer] = PlayerName[j];
}
}
TopScore[y][pScore] = TopInfo[killerid][Score];
TopScore[y][pPlayer] = GetName(killerid);
break;
}
else continue;
}
}