SA-MP Forums Archive
Kills and deaths - 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 and deaths (/showthread.php?tid=272438)



Kills and deaths - emokidx - 28.07.2011

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


Re: Kills and deaths - Calgon - 28.07.2011

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



Re: Kills and deaths - emokidx - 28.07.2011

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?


Re: Kills and deaths - Calgon - 28.07.2011

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



Re: Kills and deaths - emokidx - 28.07.2011

thnkz a lot