Paulster1022
If I remember correctly, ham_primary attack goes before ham_takedamage. You can use a "post" version of the function to detect missed player or not.
Also inflictor is weapon_entity, not weapon id! Weapon is not a part of player, it's a separate entity that lives it's own life.
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <hamsandwich>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
const OFFSET_LINUX_WEAPONS = 4
const OFFSET_WEAPONOWNER = 41
new g_maxplayers
new hits[33]
new shots[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_awp", "ham_Weapon_PrimaryAttack")
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_awp", "ham_Weapon_PrimaryAttack_Post", 1)
RegisterHam(Ham_TakeDamage, "player", "ham_TakeDamage")
g_maxplayers=get_maxplayers()
}
public ham_TakeDamage(victim, inflictor, attacker, Float:damage)
{
if (get_user_weapon(attacker)!=CSW_AWP)
return HAM_IGNORED
hits[attacker]++
client_print(0, print_chat, "player %d hit %d with awp!", attacker, victim)
return HAM_IGNORED
}
public ham_Weapon_PrimaryAttack(weapon_entity)
{
static attacker
attacker = get_pdata_cbase(weapon_entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
if (attacker<1||attacker>g_maxplayers)
return HAM_IGNORED
shots[attacker]++
client_print(0, print_chat, "player %d fires awp!", attacker)
return HAM_IGNORED
}
public ham_Weapon_PrimaryAttack_Post(weapon_entity)
{
static attacker
attacker = get_pdata_cbase(weapon_entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
if (attacker<1||attacker>g_maxplayers)
return HAM_IGNORED
client_print(0, print_chat, "player %d missed %d times!", attacker, shots[attacker]-hits[attacker])
return HAM_IGNORED
}
You can find some interesting information here:
http://forums.alliedmods.net/showthread.php?t=93229
__________________