Kills and deaths
#1

hello
i want some help in defining the kills and the deaths of a player..
like i have a /stats command
it has
pawn Код:
format(string, sizeof(string), "[Kills]%d [Deaths]%d",KILLS DEFINE, DEATHS DEFINE);
SendClientMessage(ID, green, string);
something like this

so how will i get the players kills and deahts?

regards
emokid
Reply
#2

You can declare 2 global variables for every player (or PVars) of which values are set by the OnPlayerDeath callback. This example I've created is uses PVars:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)  {
   SetPVarInt(playerid, "Deaths", GetPVarInt(playerid, "Deaths")+1);
   SetPVarInt(killerid, "Kills", GetPVarInt(killerid, "Kills")+1);
   return 1;
}
Then you can use the following code:
pawn Код:
format(string, sizeof(string), "[Kills]%d [Deaths]%d", GetPVarInt(ID, "Kills"), GetPVarInt(ID, "Deaths"));
SendClientMessage(ID, green, string);
Reply
#3

okay

so its the PVar creats something like GetPlayerDeaths
hmm ._.

oh and one thing more
how to show player id's when he says something?
Reply
#4

PVars are another form of storing data. You can read more about what they are here.

As for showing the player's ID when they speak in chat, you can change your OnPlayerText callback to contain the following code:

pawn Код:
public OnPlayerText(playerid, text[]) {
    new
        szText[128],
        szPlayerName[MAX_PLAYER_NAME];

    format(szText, sizeof(szText), "%s [%d] says: %s", szPlayerName, playerid, text);
    SendClientMessageToAll(COLOUR, szText); // You need to specify a colour where 'COLOUR' is
    return 0;
}
Reply
#5

thnkz a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)