Kill Counter
#1

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!
Reply
#2

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
Reply
#3

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.
Reply
#4

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

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

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)