Raised This Month: $ Target: $400
 0% 

Function to check wall kill?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-31-2015 , 07:17   Re: [HELP] Function to check wall kill?
Reply With Quote #1

Quote:
Originally Posted by HamletEagle View Post
What do you want to check ? If the player hits a wall when shooting ?
I want to check if player killed victim with a headshot through a wall.

I can check with DeathMsg event a simple headshot (hitted not through a wall)
PHP Code:
register_event("DeathMsg""hook_death""a""1>0"
But I don't mind how to register a headshot through a wall..
PHP Code:
public hook_death()
{
    
iAttacker read_data(1)
    
    if ( (
read_data(3) == 1) && (read_data(5) == 0) )
    {
        
// is headshot (not wallbang)
    
}

Hope you understand what i mean, thanks!
CHE4TER is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 07:28   Re: [HELP] Function to check wall kill?
Reply With Quote #2

Definitely doable. Try this and see if it works:
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new const Version[] = "0.1";

#define MAX_PLAYERS 32

new bool:g_bLastAttackWasWallMAX_PLAYERS ][ MAX_PLAYERS ];

#define IsPlayer(%1)    ( 1 <= %1 <= MAX_PLAYERS )

public plugin_init()
{
    
register_plugin"Check Wall Kill" Version "bugsy" );
    
    
RegisterHamHam_TraceAttack "player" "Player_TraceAttack" );
    
register_event"DeathMsg" "Ev_DeathMsg" "a" "1>0" );
}

public 
Player_TraceAttackiEnt iAttacker Float:flDamage Float:fDir] , ptr iDamageType )
{
    if( 
IsPlayeriAttacker ) )
    {
        if ( 
iDamageType DMG_BULLET )
        {
            new 
Float:fEnd];
            
get_tr2ptr TR_vecEndPos fEnd );
            
            
g_bLastAttackWasWalliEnt ][ iAttacker ] = bool:!ExecuteHamHam_FVecVisible iAttacker fEnd );
        }
        else
        {
            
g_bLastAttackWasWalliEnt ][ iAttacker ] = false;
        }
    }
}  

public 
Ev_DeathMsg()
{
    new 
iKiller read_data);
    new 
iVictim read_data);
    new 
iIsHeadshot read_data);
    
    if ( 
iIsHeadshot && ( g_bLastAttackWasWalliVictim ][ iKiller ] == true ) )
    {
        
client_printprint_chat "Headshot wall kill" );
    }

__________________

Last edited by Bugsy; 10-31-2015 at 07:41.
Bugsy is offline
Reply



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 18:04.


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