Player Win reward
#2

here u go:
Код:
enum rankingEnum
{
	player_Score,
	player_ID
}

stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
	new
	    tempLeft = left,
	    tempRight = right,
	    pivot = array[(left + right) / 2][player_Score],
	    tempVar
	;
 	while(tempLeft <= tempRight)
	{
	    while(array[tempLeft][player_Score] > pivot) tempLeft++;
	    while(array[tempRight][player_Score] < pivot) tempRight--;
	    
	    if(tempLeft <= tempRight)
	    {
	        tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
			tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
			tempLeft++, tempRight--;
	    }
	}
	if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
	if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
example of usage:
Код:
new
	playerScores[MAX_PLAYERS][rankingEnum],
	index
;
for(new i; i != MAX_PLAYERS; ++i)
{
	if(IsPlayerConnected(i) && !IsPlayerNPC(i))
	{
		playerScores[index][player_Score] = GetPlayerScore(i);
		playerScores[index][player_ID] = i;
		++index;
	}
}
GetPlayerHighestScores(playerScores, 0, index);
and give money to the first player:
Код:
	printf("Player %d with %d kills got 9999$", playerScores[0][player_ID], playerScores[0][player_Score], 0);
source: https://sampforum.blast.hk/showthread.php?pid=1092420#pid1092420
Reply


Messages In This Thread
Player Win reward - by Fantje - 07.10.2015, 16:43
Re: Player Win reward - by Dusan01 - 07.10.2015, 16:50
Re: Player Win reward - by Fantje - 07.10.2015, 16:57
Re: Player Win reward - by Dusan01 - 07.10.2015, 17:05
Re: Player Win reward - by Fantje - 07.10.2015, 17:12
Re: Player Win reward - by Dusan01 - 07.10.2015, 17:22

Forum Jump:


Users browsing this thread: 1 Guest(s)