untested. Also, i didn't add "Knife deaths", i'm inactive so you're lucky i considered editing this one... let me know if it works. FYI: You still gotta setup the x & y position of the hud message so that it appears under the radar and not in the middle of your screen.
PHP Code:
#include <amxmodx>
#include <nvault>
#pragma semicolon 1
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32;
#endif
#if AMXX_VERSION_NUM < 183
#define client_disconnected(%1) client_disconnect(%1)
#endif
new const szVersion[] = "1.0.0";
new iKnifeCount[MAX_PLAYERS + 1];
new iVault;
public plugin_init() {
register_plugin("KnifeKillCount", szVersion, "NapoleoN#");
register_clcmd("say /kc", "KnifeCount");
register_event("DeathMsg", "eDeath", "a", "1>0", "1!2");
iVault = nvault_open("KnifeKillCount");
}
public plugin_end() {
nvault_close(iVault);
}
public client_authorized(id) {
LoadData(id);
}
public client_putinserver(id)
{
set_task(20.0, "DisplayHud", id, _, _, "b");
}
public client_disconnected(id)
{
SaveData(id);
// Remove task on disconnect? Sounds pointless lol.
}
public eDeath() {
new iAttacker = read_data(1);
new iClip, iAmmo, iWeapon;
iWeapon = get_user_weapon(iAttacker, iClip, iAmmo);
if(iWeapon == CSW_KNIFE && is_user_connected(iAttacker)) {
iKnifeCount[iAttacker]++;
}
}
public KnifeCount(id) {
client_print(id, print_chat, "Knife KillCount: %i", iKnifeCount[id]);
}
public DisplayHud(id)
{
if(is_user_connected(id))
{
set_hudmessage(200, 100, 0, -1.0, 0.35, 0, 0.0, 20.0, 0.0, 0.0, -1);
show_hudmessage(id, "Knife KillCount: %i", iKnifeCount[id]);
}
}
SaveData(id) {
new szAuth[35], szTemp[10];
get_user_authid(id, szAuth, charsmax(szAuth));
formatex(szTemp, charsmax(szTemp), "%i", iKnifeCount[id]);
nvault_set(iVault, szAuth, szTemp);
}
LoadData(id) {
new szAuth[35], szKillCount[10], szTemp[10];
get_user_authid(id, szAuth, charsmax(szAuth));
nvault_get(iVault, szAuth, szTemp, charsmax(szTemp));
parse(szTemp, szKillCount, charsmax(szKillCount));
iKnifeCount[id] = str_to_num(szKillCount);
}
__________________