Player Win reward
#1

Heey!

I am making a DM server and I want that if the time is over the player with the most KILLS will win ( a message shows up for everyone ) and get some cash. Can anyone help me?

Peace


This is easy I know but I am beginner so help me out
Reply
#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
#3

PHP код:
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(24) : error 010invalid function or declaration
C
:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(26) : error 010invalid function or declaration
C
:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(857) : error 025: function heading differs from prototype
C
:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(877) : error 035argument type mismatch (argument 1)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(878) : error 035argument type mismatch (argument 1)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(880) : warning 203symbol is never used"index" 
Reply
#4

give me the lines where are errors
Reply
#5

PHP код:
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(24) : error 010invalid function or declaration // for (new(i; i != MAX_PLAYERS; ++i)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(26) : error 010invalid function or declaration // if(IsPlayerConnected(i) && !IsPlayerNPC(i))
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(857) : error 025: function heading differs from prototype // stock GetPlayerHighestScores(array[][rankingEnum], left, right)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(877) : error 035argument type mismatch (argument 1// if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(878) : error 035argument type mismatch (argument 1// if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(880) : warning 203symbol is never used"index" // The last line is  880 so index is never used 
Reply
#6

you did not copyed code, or u put it on wrong place and thats why u got errors...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)