SA-MP Forums Archive
Kill Counter - 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: Kill Counter (/showthread.php?tid=112066)



Kill Counter - Ironboy500 - 05.12.2009

I have two working teams defined, TEAM_FIREMAN and TEAM_MEDIC. Can anyone give me working code and tested one who counts number of kills? I really need it. Thanks.

EDIT: I searched and all codes I found are not working!


Re: Kill Counter - DJDhan - 05.12.2009

It's got to do with OnPlayerDeath function.
I'm fairly new to coding but...

You can add a new variable with arguments playerid and kills like so
Код:
new PlayerInfo[MAX_PLAYERS][PlayerData];
enum PlayerData
{ Kills;
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
public OnPlayerConnect(playerid)
{PlayerInfo[playerid][Kills] = 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{      PlayerInfo[playerid][Deaths]++
       SendDeathMessage(killerid, playerid, reason);

}
Hope I Helped


Re: Kill Counter - Daren_Jacobson - 05.12.2009

Quote:
Originally Posted by DJDhan
It's got to do with OnPlayerDeath function.
I'm fairly new to coding but...

You can add a new variable with arguments playerid and kills like so
Код:
new PlayerInfo[MAX_PLAYERS][PlayerData];
enum PlayerData
{ Kills;
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
public OnPlayerConnect(playerid)
{PlayerInfo[playerid][Kills] = 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{     PlayerInfo[playerid][Deaths]++
      SendDeathMessage(killerid, playerid, reason);

}
Hope I Helped
you must be really new, cause that is hurting my eyes.

pawn Код:
new pKills[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
    pKills[playerid] = 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    pKills[killerid]++;
    SendDeathMessage(killerid, playerid, reason);

}
that would make a variable holding how many kills each player has. what you do with it is entirely up to you.


Re: Kill Counter - Sergei - 05.12.2009

Probably he won't save only kills, that's why he made up example with enum.


Re: Kill Counter - Ironboy500 - 05.12.2009

Thank you all! I found out how to do it!
Thanks! :P


Re: Kill Counter - DJDhan - 06.12.2009

oops i repeated the new playrinfo line
and the semicolon
Ye good you found it out.
An yeh you could save almost all info for the player in enum playerinfo
Cheers
Dhananjay