SA-MP Forums Archive
kills/deaths per round - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: kills/deaths per round (/showthread.php?tid=228022)



kills/deaths per round - BlackWolf120 - 18.02.2011

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?


Re: kills/deaths per round - (SF)Noobanatior - 18.02.2011

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



Re: kills/deaths per round - BlackWolf120 - 18.02.2011

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)


AW: kills/deaths per round - !Phoenix! - 18.02.2011

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


Re: kills/deaths per round - Finn - 18.02.2011

killerid can be INVALID_PLAYER_ID.

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



Re: kills/deaths per round - BlackWolf120 - 18.02.2011

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);
            }
        }
    }



Re: kills/deaths per round - (SF)Noobanatior - 18.02.2011

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?


Re: kills/deaths per round - BlackWolf120 - 19.02.2011

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


Re: kills/deaths per round - [WF]Demon - 19.02.2011

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


Re: kills/deaths per round - (SF)Noobanatior - 19.02.2011

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