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 , 06:20   Function to check wall kill?
Reply With Quote #1

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

public plugin_init()
{
    
RegisterHam(Ham_TraceAttack"player""CBasePlayer_TraceAttack")
}

public 
CBasePlayer_TraceAttack(iVictimiAttackerFloat:flDamageFloat:vDirection], ptrBits 
{
    if( 
iAttacker && get_user_weaponiAttacker ) != CSW_KNIFE 
    {
        static 
Float:vStart], Float:vEnd], Float:flFraction;

        
get_tr2ptrTR_vecEndPosvEnd ); 
        
get_tr2ptrTR_flFractionflFraction ); 

        
xs_vec_mul_scalarvDirection, -1.0vDirection ); 
        
xs_vec_mul_scalarvDirectionflFraction 9999.0vStart ); 
        
xs_vec_addvStartvEndvStart ); 

        new 
iTarget trace_lineiVictimvEndvStartvEnd ); 

        if( !
iTarget )
        {
        
// attacker is hitting victim
        
}
        

        
// Check if attacker killed victim?
    
}


Last edited by CHE4TER; 02-28-2016 at 23:04.
CHE4TER is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-31-2015 , 07:04   Re: [HELP] Function to check wall kill?
Reply With Quote #2

What do you want to check ? If the player hits a wall when shooting ?
__________________
HamletEagle is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-31-2015 , 07:17   Re: [HELP] Function to check wall kill?
Reply With Quote #3

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 #4

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
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 07:13   Re: [HELP] Function to check wall kill?
Reply With Quote #5

It sounds like he wants to detect when a player killed another player through a wall.
__________________

Last edited by Bugsy; 10-31-2015 at 07:19.
Bugsy is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-31-2015 , 07:33   Re: [HELP] Function to check wall kill?
Reply With Quote #6

Won't compile.

Error: Undefined symbol "MAX_PLAYERS" on line 9
Error: Invalid array size (negative or zero) on line 9

Line 9: new bool:g_bLastAttackWasWall[ MAX_PLAYERS + 1 ][ MAX_PLAYERS + 1 ];

Last edited by CHE4TER; 10-31-2015 at 07:33.
CHE4TER is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 07:34   Re: [HELP] Function to check wall kill?
Reply With Quote #7

Sorry try now
__________________
Bugsy is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-31-2015 , 07:41   Re: [HELP] Function to check wall kill?
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
Sorry try now
You removed the "const MAX_PLAYERS = 32"?
Still getting the same error. If I add that const MAX_PLAYERS, plugin is compiling, but my server crashes.
CHE4TER is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-31-2015 , 07:57   Re: [HELP] Function to check wall kill?
Reply With Quote #9

I edited it again, try that. Sorry, this is due to a constant for MAX_PLAYERS being added to AMX-X 1.8.3. Working for me with no crash.
__________________

Last edited by Bugsy; 10-31-2015 at 08:01.
Bugsy is offline
CHE4TER
Member
Join Date: Jul 2013
Location: Portugal
Old 10-31-2015 , 08:08   Re: [HELP] Function to check wall kill?
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
I edited it again, try that. Sorry, this is due to a constant for MAX_PLAYERS being added to AMX-X 1.8.3. Working for me with no crash.
When i hit a player my server crash. What's wrong?

Last edited by CHE4TER; 10-31-2015 at 08:09.
CHE4TER 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:03.


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