This is possible?
#1

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(IsPlayerConnected(i))
	{
		for(new a = 0; a < MAX_PLAYERS; a != i; a++)
		{
			if(IsPlayerConnecteD(a))
			{
			}
		}
	}
{
Reply
#2

why loop two times MAX_PLAYERS?? seems weird ...if you explain more what you want to do...
Reply
#3

actually I cant see the reason for nested player loops but its possible
Just get foreach, it uses an advanced structure to create a faster loops
Reply
#4

okay, because I want to use variables in it for my scoreboard in the end of the session, like who has the most kills etc. But is there a way to ingnore if a and i are the same?
Reply
#5

Quote:
Originally Posted by timothyinthehouse
Посмотреть сообщение
okay, because I want to use variables in it for my scoreboard in the end of the session, like who has the most kills etc. But is there a way to ingnore if a and i are the same?
pawn Код:
(a < MAX_PLAYERS) && (a != i)
But there are better sorting methodes than two player loops

That would be Insertionsort, just ****** Sorting algorithm for more advanced once
Some advanced sorthing algorithm like quicksort can be found in this forum

pawn Код:
new
    i,
    j,
    id,
    value,
    id[sizeof Kills] = {0, 1, 2, ...};
for( ; i != sizeof Kills; ++i) {
    value = Kills[i];
    for(j = i; (j != 0) && (Kills[id[j - 1]] < value); --j) {
        id[j] = id[j - 1]
    }
    id[j] = i;
}
//id[0] is the id with the most kills (Kills[id[0]] would be the kills)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)