How to get a players total kills (On the server)
#1

How can you see how many kills the player has done on the server? This will count all the kills he has done since he started playing on the server.

Can someone create a stock and show the code or tell me how to? I really need this for my war server.
Reply
#2

Use a variable which you increase for killerid under OnPlayerDeath. Save this value when they disconnect. IMPORTANT: You MUST check that killerid is NOT INVALID_PLAYER_ID before you use an array with [killerid]. If it is suicide OnPlayerDeath will stop executing.

To increase an array's value:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        pKills[killerid]++;
    }
    return 1;
}
Reply
#3

I have never created an array, can you show me how?
Reply
#4

new pKills[MAX_PLAYERS];

Outside all callbacks/functions, which will make it 'global'.
Reply
#5

But isn't there a
pawn Код:
pKills[MAX_PLAYERS]; = //Function here
Reply
#6

What..?
Reply
#7

I mean that isn't that there?
Where says "Function here", thats where you put what pKills means.

And i also need to know how to save it when they disconnect.

EDIT: And also i am using this for rank system depending on how much kills they have total.
Reply
#8

If you want it to save when player quit then you gotta have register system...
Reply
#9

I use LuxAdmin's register system.
Reply
#10

Sorry for the bump,
But for array:
How would i use it to see how many total kills they have?

Is it like this:
pawn Код:
if(pKills >= 50 && <= 60)
{
    SetPlayerHealth(playerid, 999999);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)