PDA

View Full Version : Help Please in Top 5 system.


Champ
26/09/2013, 05:21 PM
I got a serious problem. When player joins, its alright. it shows the top list like this ↓


1. Champ
2. Stranger
3. N/A
4. N/A
5. N/A


but when i kill some one. it shows it like this.


1. Champ
2. Champ
3. N/A
4. N/A
5. N/A


I have created a variable for it. Here is it.


new score[MAX_PLAYERS];

public OnPlayerDeath(playerid)
(
score[killerid]++;
)



and



for(new i; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
playerScores[index][player_Score] = score[i];
playerScores[index++][player_ID] = i;
}
}

Please help.

Patrick
26/09/2013, 06:33 PM
I noticed something on your OnPlayerDeath Callback

Remove this

public OnPlayerDeath(playerid)


and Change it to this

public OnPlayerDeath(playerid, killerid, reason)

Konstantinos
26/09/2013, 07:00 PM
That would give an error about function heading differs from prototype. I guess it was a typing mistake while writing the thread.

When you pass killerid in an array, you need to make sure first that the player is valid - otherwise a runtime error about index out of bounds will be caused.

if(killerid != INVALID_PLAYER_ID) score[killerid]++;

Champ
27/09/2013, 10:37 AM
Ok, Konstantinos. I will try this .
Thank You :)