kills/deaths per round
#1

hi,
how would u count the kills/deaths of a player he made in one round?

ive ried it like this but it doesnt seem to work!

pawn Код:
new KillsInRound[MAX_PLAYERS];
new DeathsInRound[MAX_PLAYERS];

//OnPlayerDeath

KillsInRound[killerid]++;
DeathsInRound[playerid]++;

//as soon as new round begins i reset them

KillsInRound[playerid]=0;
DeathsInRound[playerid]=0;
can someone tell me whats wrong pls?
Reply
#2

that should work are these two at the top of you script?
pawn Код:
new KillsInRound[MAX_PLAYERS];
new DeathsInRound[MAX_PLAYERS];
Reply
#3

yep.
i know, it should work.
But i just dont know where the error is.
It doesnt count right.
I think the problem is:
pawn Код:
//OnPlayerDeath

KillsInRound[killerid]++;
cause the code thats under this part just is not red/executed anymore.(just like id put a return 1; there)
Reply
#4

So I would say we need some more code.
It looks correct to me as well.
Reply
#5

killerid can be INVALID_PLAYER_ID.

pawn Код:
if(killerid != INVALID_PLAYER_ID)
{
    KillsInRound[killerid]++;
}
Reply
#6

thx for ur answers.

But i already tried it like this:

pawn Код:
DeathsInRound[playerid]++;
if(killerid!=INVALID_PLAYER_ID)
{
KillsInRound[killerid]++;
}
But maybe the error is here, can i compare the kills of the players like this?
pawn Код:
new TotalScores[21];//21 cause i wanna compare 20 players.
new TotalPlayers[21];
new PlayerScore[2];
new PlayerID[2];
for(new i; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        PlayerScore[0] = KillsInRound[i]; //killsperround
        PlayerID[0] = i;
        for(new place; place < sizeof(TotalScores); place++)
        {
            if(PlayerScore[0] > TotalScores[place])
            {
                strins(TotalScores, PlayerScore, place);
                strins(TotalPlayers, PlayerID, place);
                place = sizeof(TotalScores);
            }
        }
    }
Reply
#7

yep that will be you problem what actually are you trying to do? count kills and deaths and then rank them 1st to 20th based on there overall position?
Reply
#8

thats right.
I want to list 20 players. Their position depends on their amount of kills.
Itd be nice if someone could help me.
Reply
#9

try += 1; instead of ++; if that does not work then OnPlayerDeath is not being called (?)
Reply
#10

ok so i cant really test it as i dont have players on hand but i would go something like
pawn Код:
//Globals
new KillsInRound[MAX_PLAYERS];
new DeathsInRound[MAX_PLAYERS];

//Function
stock PrintRanksInRound(){
    new Place = 1;
    new PreviousHighScore;
    for(new j=0;j<MAX_PLAYERS;j++){
        new HighScore;
        for(new i=0;i<MAX_PLAYERS;i++){
            if(!IsPlayerConnected(i))continue;
            if(KillsInRound[i] > KillsInRound[HighScore]){
                HighScore = i;
            }
        }
        new str[5];
        if(PreviousHighScore == KillsInRound[HighScore] && PreviousHighScore != 0)Place--;
        if(place == 1)str = "st";
        else if(place == 2)str = "nd";
        else str = "rd";
        printf("ID %d placed %d%s with %d Kills",HighScore,Place,str,KillsInRound[HighScore]);
        PreviousHighScore = KillsInRound[HighScore];
        KillsInRound[HighScore] = 0;
        Place++;
    }
}
and you properly nee to got
pawn Код:
#pragma unused j
to clear the last error in the compiler
let me know how ya get on
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)