For weapon name, use 4th DeathMsg arg (get_user_weapon fails on grenade kills).
To prevent errors when players are killed by world, add filter "1>0" in register_event
To prevent errors when players are killed by entities, check is killer index is a player index.
PHP Code:
new g_iMaxPlayers;
#define IsPlayer(%0) ( 1 <= (%0) <= g_iMaxPlayers )
public plugin_init()
{
register_event("DeathMsg", "event_DeathMsg", "a", "1>0");
g_iMaxPlayers = get_maxplayers();
}
public event_DeathMsg(id)
{
new iKiller = read_data(1);
new iVictim = read_data(2);
if(iKiller != iVictim && IsPlayer(iKiller))
{
new name[32], szWeapon[32];
get_user_name(iKiller, name, charsmax(name));
read_data(4, szWeapon, charsmax(szWeapon));
chat_color(iVictim, "!nKilled by !t%s !nwith !g%s !nand remained with !g%d !nhp", name, szWeapon, get_user_health(iKiller));
}
}
Also, at other places than DeathMsg callback, if you have a weapon name with format "weapon_****" and you want to print it without 'weapon_', just do :
PHP Code:
"weapon is %s", szWeapon[7]
Don't use replace it is not needed at all.
__________________