Raised This Month: $ Target: $400
 0% 

Best way to Detect Hit/Miss with Awp.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 04-24-2011 , 12:38   Re: Best way to Detect Hit/Miss with Awp.
Reply With Quote #4

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(PLUGINVERSIONAUTHOR)
    
    
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(victiminflictorattackerFloat:damage)
{
    if (
get_user_weapon(attacker)!=CSW_AWP)
        return 
HAM_IGNORED

    hits
[attacker]++
    
    
client_print(0print_chat"player %d hit %d with awp!"attackervictim)
    
    return 
HAM_IGNORED
}

public 
ham_Weapon_PrimaryAttack(weapon_entity)
{
    static 
attacker
    
    attacker 
get_pdata_cbase(weapon_entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);
    
    if (
attacker<1||attacker>g_maxplayers)
        return 
HAM_IGNORED
    
    shots
[attacker]++
    
    
client_print(0print_chat"player %d fires awp!"attacker)
    
    return 
HAM_IGNORED
}

public 
ham_Weapon_PrimaryAttack_Post(weapon_entity)
{
    static 
attacker
    
    attacker 
get_pdata_cbase(weapon_entityOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS);
    
    if (
attacker<1||attacker>g_maxplayers)
        return 
HAM_IGNORED
    
    client_print
(0print_chat"player %d  missed %d times!"attackershots[attacker]-hits[attacker])
    
    return 
HAM_IGNORED

You can find some interesting information here: http://forums.alliedmods.net/showthread.php?t=93229
__________________


Last edited by SonicSonedit; 04-24-2011 at 12:53.
SonicSonedit is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode