Player Win reward - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player Win reward (
/showthread.php?tid=591063)
Player Win reward -
Fantje - 07.10.2015
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
Re: Player Win reward -
Dusan01 - 07.10.2015
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
Re: Player Win reward -
Fantje - 07.10.2015
PHP код:
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(24) : error 010: invalid function or declaration
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(26) : error 010: invalid 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 035: argument type mismatch (argument 1)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(878) : error 035: argument type mismatch (argument 1)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(880) : warning 203: symbol is never used: "index"
Re: Player Win reward -
Dusan01 - 07.10.2015
give me the lines where are errors
Re: Player Win reward -
Fantje - 07.10.2015
PHP код:
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(24) : error 010: invalid function or declaration // for (new(i; i != MAX_PLAYERS; ++i)
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(26) : error 010: invalid 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 035: argument type mismatch (argument 1) // if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(878) : error 035: argument type mismatch (argument 1) // if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
C:\Users\Mike\Desktop\DMserver\gamemodes\CastleRush.pwn(880) : warning 203: symbol is never used: "index" // The last line is 880 so index is never used
Re: Player Win reward -
Dusan01 - 07.10.2015
you did not copyed code, or u put it on wrong place and thats why u got errors...