AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Function to check wall kill? (https://forums.alliedmods.net/showthread.php?t=273997)

CHE4TER 10-31-2015 06:20

Function to check wall kill?
 
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?
    
}



HamletEagle 10-31-2015 07:04

Re: [HELP] Function to check wall kill?
 
What do you want to check ? If the player hits a wall when shooting ?

Bugsy 10-31-2015 07:13

Re: [HELP] Function to check wall kill?
 
It sounds like he wants to detect when a player killed another player through a wall.

CHE4TER 10-31-2015 07:17

Re: [HELP] Function to check wall kill?
 
Quote:

Originally Posted by HamletEagle (Post 2358282)
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!

Bugsy 10-31-2015 07:28

Re: [HELP] Function to check wall kill?
 
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" );
    }



CHE4TER 10-31-2015 07:33

Re: [HELP] Function to check wall kill?
 
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 ];

Bugsy 10-31-2015 07:34

Re: [HELP] Function to check wall kill?
 
Sorry try now

CHE4TER 10-31-2015 07:41

Re: [HELP] Function to check wall kill?
 
Quote:

Originally Posted by Bugsy (Post 2358296)
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.

Bugsy 10-31-2015 07:57

Re: [HELP] Function to check wall kill?
 
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.
https://dl.dropboxusercontent.com/u/97433215/CS.png

CHE4TER 10-31-2015 08:08

Re: [HELP] Function to check wall kill?
 
Quote:

Originally Posted by Bugsy (Post 2358301)
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.
https://dl.dropboxusercontent.com/u/97433215/CS.png

When i hit a player my server crash. What's wrong?


All times are GMT -4. The time now is 18:04.

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