Raised This Month: $ Target: $400
 0% 

Solved EngFunc_TraceTexture result is only NoTexture


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AimniX
New Member
Join Date: May 2020
Old 05-04-2020 , 18:39   EngFunc_TraceTexture result is only NoTexture
Reply With Quote #1

Hy, i try to make a AntiWallbang plugin.
So far it works but it should be possible to shot thrue wooden textures.
EngFunc_TraceTexture gives me only "NoTexture".
what do i wrong?

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




new const Version[] = "1.0";

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

public plugin_init()
{
    
register_plugin"Anti_Wallbang" Version "AimniX" );
    
    
RegisterHamHam_TraceAttack "player" "Player_TraceAttack" );

}

public 
Player_TraceAttackiEnt iAttacker Float:flDamage Float:fDir] , ptr iDamageType )
{
    if( 
IsPlayeriAttacker ) )
    {
        if ( 
iDamageType DMG_BULLET )
        {
            new 
Float:fEnd];
            
get_tr2ptr TR_vecEndPos fEnd);
            
            if(
bool:!ExecuteHamHam_FVecVisible iAttacker fEnd )!= false)
        {
            new 
startOrigin[3
            
get_user_origin(iAttackerstartOrigin 1);
            
            new 
endOrigin[3]
            
get_user_origin(iAttackerendOrigin 4);

            
            new 
texture_name[64],texture_type
            engfunc
(EngFunc_TraceTexture0startOrigin endOrigintexture_namecharsmax(texture_name))
            
texture_type dllfunc(DLLFunc_PM_FindTextureTypetexture_name)

            
client_print0print_chat"This is the Texture: %s",texture_type)


    
            
            
            return 
HAM_SUPERCEDE
        
}
        }
        else
        {
            return 
HAM_IGNORED
        
}
    }
    return 
HAM_IGNORED


Last edited by AimniX; 05-07-2020 at 20:35. Reason: Solved
AimniX is offline
AimniX
New Member
Join Date: May 2020
Old 05-07-2020 , 20:32   Re: EngFunc_TraceTexture result is only NoTexture
Reply With Quote #2

hy guys, i find it out by reading many posts on this forum an many other sites.
the distance between the two points that you have to give to the function (startOrigin,endOrigin)

PHP Code:
engfunc(EngFunc_TraceTexture0startOrigin endOrigintexture_namecharsmax(texture_name)) 
has to be longer than 2000.0 .
in a post from Arkshine i found a calculation function that helps me a lot to calculate the new endpoint.

PHP Code:
enum _:Angle_t Float:PitchFloat:YawFloat:Roll };
enum _:Coord_t Float:xFloat:yFloat:};

#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )

            
const Float:LENGTH 8000.0;
            new 
Float:endOriginCoord_t ];
            new 
Float:startOriginCoord_t ];
            new 
Float:dirForwardCoord_t ];
            new 
Float:viewAnglesAngle_t ];
    
            
peviAttackerpev_originstartOrigin );
            
peviAttackerpev_v_angleviewAngles );
    
            
engfuncEngFunc_MakeVectorsviewAngles );
            
global_getglb_v_forwarddirForward );
    
            
VectorMAstartOriginLENGTHdirForwardendOrigin ); 
here the full code of my plugin that seems to work^^

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


new const Version[] = "1.0";

enum _:Angle_t Float:PitchFloat:YawFloat:Roll };
enum _:Coord_t Float:xFloat:yFloat:};

#define VectorMA(%0,%1,%2,%3) ( %3[ x ] = %0[ x ] + %1 * %2[ x ], %3[ y ] = %0[ y ] + %1 * %2[ y ], %3[ z ] = %0[ z ] + %1 * %2[ z ] )



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



public plugin_init()
{
    
register_plugin"Anti_Wallbang" Version "AimniX" );
    
    
RegisterHamHam_TraceAttack "player" "Player_TraceAttack" );

}

public 
Player_TraceAttackiEnt iAttacker Float:flDamage Float:fDir] , ptr iDamageType )
{
    if( 
IsPlayeriAttacker ) )
    {
        if ( 
iDamageType DMG_BULLET )
        {
    new 
Float:fEnd[3]
    new 
Float:normal[3]
    new 
hit
    get_tr2
ptr TR_vecEndPos fEnd TR_vecPlaneNormalnormalTR_pHit,hit);
    
    if(
bool:!ExecuteHamHam_FVecVisible iAttacker fEnd )!= false)
        {
            
            const 
Float:LENGTH 8000.0;
            new 
Float:endOriginCoord_t ];
            new 
Float:startOriginCoord_t ];
            new 
Float:dirForwardCoord_t ];
            new 
Float:viewAnglesAngle_t ];
    
            
peviAttackerpev_originstartOrigin );
            
peviAttackerpev_v_angleviewAngles );
    
            
engfuncEngFunc_MakeVectorsviewAngles );
            
global_getglb_v_forwarddirForward );
    
            
VectorMAstartOriginLENGTHdirForwardendOrigin );
            
            
            
            
            new 
texture_name[32],texture_type[1]
            
engfunc(EngFunc_TraceTexture0startOrigin endOrigintexture_namecharsmax(texture_name))
            
texture_type[0] = dllfunc(DLLFunc_PM_FindTextureTypetexture_name)

            
client_print0print_chat"This is the Texture: %s",texture_type)
            new 
wood[] = "W";
            if(
texture_type[0] == wood[0])
            {
                
                return 
HAM_IGNORED;
            }
            
    
            
            
            return 
HAM_SUPERCEDE
        
}
        }
        else
        {
            return 
HAM_IGNORED
        
}
    }
    return 
HAM_IGNORED

AimniX 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 16:52.


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