View Single Post
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 04-04-2023 , 17:43   Re: [TUT] Properly Detect Weapon Shot (Every Shot)
Reply With Quote #5

@ Celena Luna, here is the final proof that Ham_Weapon_PrimaryAttack_<Pre> is not better, it counts player is shooting when has no bullets.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

#define valid(id) (id == clamp(id,1,33)) 
#define NOSHOT (1<<0 | 1<<4 | 1<<6 | 1<<9 | 1<<25 | 1<<29)

new shot_count;

public 
plugin_init() {
    
register_plugin("Shot Hook","1.0","WATCH_DOGS UNITED")

    new 
weapon_name[20]
    for(new 
CSW_P228<= CSW_P90i++) {
        if(
get_weaponname(i,weapon_name,charsmax(weapon_name)) && !(NOSHOT 1<<i))
            
RegisterHam(Ham_Weapon_PrimaryAttack,weapon_name,"Ham_Weapon_PrimaryAttack_Pre")
    }
    
register_forward(FM_TraceLine,"Real_Time_Debug",1)
}

public 
Ham_Weapon_PrimaryAttack_Pre()
    
shot_count++

public 
Real_Time_Debug(const Float:start[3],Float:dest[3],HIT_PARAM,id,ptr) {
    if(
valid(id))
        
client_print(id,print_chat,"SHOTS: %d",shot_count)

@JusTGo, we will take a look. Thanks!

EDIT:

Could you provide a link?

Last edited by WATCH_D0GS UNITED; 04-04-2023 at 17:46.
WATCH_D0GS UNITED is offline