AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Code doenst work (https://forums.alliedmods.net/showthread.php?t=220975)

UchihaSkills 07-16-2013 14:24

Code doenst work
 
PHP Code:

    new bool:bFindHull;
    
    if( 
flFraction >= ) {
        
engfuncEngFunc_TraceHullvStartvEndDONT_IGNORE_MONSTERSHULL_HEADiZombieiTr );
        
        
get_tr2iTrTR_flFractionflFraction );
        
        if( 
flFraction ) {
            
pHit get_tr2iTrTR_pHit );
            
            if( !
pHit ) {
                
bFindHull true

Why my code doesnt work?

ConnorMcLeod 07-16-2013 15:25

Re: Code doenst work
 
You should show more code, also, trace_hull may be better for what you need.

UchihaSkills 07-16-2013 15:31

Re: Code doenst work
 
PHP Code:

 ZombieAttack( const iZombie ) {
    new 
Float:flFractionFloat:vStart], Float:vEnd], Float:vForward], iTr create_tr2( );
    new 
Float:vEndPos], pHit;
    
    
entity_get_vectoriZombieEV_VEC_originvStart );
    
    
entity_get_vectoriZombieEV_VEC_anglesvForward );
    
engfuncEngFunc_MakeVectorsvForward );
    
get_tr2iTrTR_flFractionflFraction ); 

I want to set it a target

UchihaSkills 07-16-2013 15:35

Re: Code doenst work
 
Quote:

Originally Posted by ConnorMcLeod (Post 1992319)
You should show more code, also, trace_hull may be better for what you need.

Why is it better to use trace_hull?

ConnorMcLeod 07-16-2013 16:29

Re: Code doenst work
 
Could you post the full ZombieAttack code please ?

trace_hull integrates some trace results in its return, so you can gain some native calls using it, dunno if it is the case in your situation.

UchihaSkills 07-16-2013 17:52

Re: Code doenst work
 
PHP Code:

 ZombieAttack( const iZombie ) {
    new 
Float:flFractionFloat:vStart], Float:vEnd], Float:vForward], iTr create_tr2( );
    new 
Float:vEndPos], pHit;
    
    
entity_get_vectoriZombieEV_VEC_originvStart );
    
    
entity_get_vectoriZombieEV_VEC_anglesvForward );
    
engfuncEngFunc_MakeVectorsvForward );
    
get_tr2iTrTR_flFractionflFraction );
    
    
vStart] += 28.0;
    
vEnd]    = vStart] + vForward] * 32.0;
    
vEnd]    = vStart] + vForward] * 32.0;
    
vEnd]    = vStart];
    
    
engfuncEngFunc_TraceLinevStartvEndDONT_IGNORE_MONSTERSiZombieiTr );
    
get_tr2iTrTR_flFractionflFraction );
    
    new 
bool:bFindHull;
    
    if( 
flFraction >= ) {
        
engfuncEngFunc_TraceHullvStartvEndDONT_IGNORE_MONSTERSHULL_HEADiZombieiTr );
        
        
get_tr2iTrTR_flFractionflFraction );
        
        if( 
flFraction ) {
            
pHit get_tr2iTrTR_pHit );
            
            if( !
pHit ) {
                
bFindHull true;
            }
        }
    } else
        
pHit get_tr2iTrTR_pHit );
    
    
get_tr2iTrTR_vecEndPosvEndPos );
    
    
free_tr2iTr );
    
    if( 
flFraction >= 1.0 || !IsPlayerpHit ) ) {
        
client_print0print_chat"[ Zombie: %i ] Missed. %s"iZombiebFindHull "FindHullIntersection!" "" ); 


ConnorMcLeod 07-16-2013 18:08

Re: Code doenst work
 
Something like this ?

PHP Code:

ZombieAttack( const iZombie )
{
    new 
Float:flFractionFloat:vStart], Float:vEnd], Float:vForward], iTr create_tr2( );
    new 
Float:vEndPos], pHit;
    
    
entity_get_vectoriZombieEV_VEC_originvStart );
    
    
entity_get_vectoriZombieEV_VEC_anglesvForward );
    
engfuncEngFunc_MakeVectorsvForward );
    
// get_tr2( iTr, TR_flFraction, flFraction ); // there is no trace yet
    
    
vStart] += 28.0;
    
vEnd]    = vStart] + vForward] * 32.0;
    
vEnd]    = vStart] + vForward] * 32.0;
    
vEnd]    = vStart];
    
    
// engfunc( EngFunc_TraceLine, vStart, vEnd, DONT_IGNORE_MONSTERS, iZombie, iTr );
    // get_tr2( iTr, TR_flFraction, flFraction );
    
pHit trace_line(iZombien vStartvEndvEndPos);
    if( !
pHit )
    {
        
engfuncEngFunc_TraceHullvStartvEndDONT_IGNORE_MONSTERSHULL_HEADiZombieiTr );
        
get_tr2iTrTR_flFractionflFraction );
        if( 
flFraction 1.0 )
        {
            
pHit get_tr2iTrTR_pHit );
            
get_tr2iTrTR_vecEndPosvEndPos );
        }
        else
        {
            
pHit FM_NULLENT;
        }
    }

    if( !
IsPlayer(pHit) )
    {
        
client_print0print_chat"[ Zombie: %i ] Missed. %s"iZombiepHit == FM_NULLENT "FindHullIntersection!" "" );  
    }



UchihaSkills 07-16-2013 18:20

Re: Code doenst work
 
so i need this on line 10 of your code? instead of the trace
PHP Code:

 global_getglb_v_forwardvForward ); 


ConnorMcLeod 07-16-2013 19:59

Re: Code doenst work
 
Yes, and you were needing it in your code to.

UchihaSkills 07-16-2013 20:02

Re: Code doenst work
 
Ok thank you it works


All times are GMT -4. The time now is 06:21.

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