AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   index out of bounds (https://forums.alliedmods.net/showthread.php?t=144275)

outsiderlv 12-01-2010 11:50

index out of bounds
 
PHP Code:

public fm_FEFindEntityInSphere(startFloat:origin[3], Float:radius)
{
    if( 
radius!=1500.0 || old_gametime!=get_gametime() )
        return 
FMRES_IGNORED;
    
    static 
hittraceFloat:user_origin[3], Float:absmax[3], Float:fraction;
    
hit start;
    
    
// run the same check to see what its result will be
    
while( (hit=engfunc(EngFunc_FindEntityInSpherehitoriginradius))>)
    {
        if(
no_flash[hit]) {
            
// hit a non- or dead-player
            
if( !is_user_alive(hit) )
            {
                
forward_return(FMV_CELLhit);
                return 
FMRES_SUPERCEDE;
            }
            
            
// aim for the body eyes
            
pev(hitpev_originuser_origin);
            
pev(hitpev_absmaxabsmax);
            
user_origin[2] = (absmax[2]-20.0);
            
engfunc(EngFunc_TraceLineoriginuser_originDONT_IGNORE_MONSTERS0trace);
            
            
// hit player eyes, grenade ok
            
if( get_tr2(traceTR_pHit)==hit )
            {
                
// start backup check (de_dust2 B bug - outmap bug)
                
engfunc(EngFunc_TraceLineuser_originoriginDONT_IGNORE_MONSTERShittrace);
                
                
// hit player eyes with backup check
                
get_tr2(traceTR_flFractionfraction);
                if( 
fraction==1.0 )
                {
                    if(
owner) {
                        
forward_return(FMV_CELL, -1);
                        return 
FMRES_SUPERCEDE;
                    }
                }
            }
        }
    }
    
    
// grenade could not hit anyones eyes, cancel the check
    
forward_return(FMV_CELL, -1);
    return 
FMRES_SUPERCEDE;


Where is the problem? Debug says that the problem is on line witch contains only "{".

YamiKaitou 12-01-2010 12:07

Re: index out of bounds
 
Which line?

outsiderlv 12-01-2010 12:08

Re: index out of bounds
 
2nd in the code

Exolent[jNr] 12-01-2010 16:41

Re: index out of bounds
 
It's probably this:
PHP Code:

        if(no_flash[hit]) { 

Move that to here:
PHP Code:

public fm_FEFindEntityInSphere(startFloat:origin[3], Float:radius)
{
    if( 
radius!=1500.0 || old_gametime!=get_gametime() )
        return 
FMRES_IGNORED;
    
    static 
hittraceFloat:user_origin[3], Float:absmax[3], Float:fraction;
    
hit start;
    
    
// run the same check to see what its result will be
    
while( (hit=engfunc(EngFunc_FindEntityInSpherehitoriginradius))>)
    {
        
// hit a non- or dead-player
        
if( !is_user_alive(hit) || !no_flash[hit] )
        {
            
forward_return(FMV_CELLhit);
            return 
FMRES_SUPERCEDE;
        }
        
        
// aim for the body eyes
        
pev(hitpev_originuser_origin);
        
pev(hitpev_absmaxabsmax);
        
user_origin[2] = (absmax[2]-20.0);
        
engfunc(EngFunc_TraceLineoriginuser_originDONT_IGNORE_MONSTERS0trace);
        
        
// hit player eyes, grenade ok
        
if( get_tr2(traceTR_pHit)==hit )
        {
            
// start backup check (de_dust2 B bug - outmap bug)
            
engfunc(EngFunc_TraceLineuser_originoriginDONT_IGNORE_MONSTERShittrace);
            
            
// hit player eyes with backup check
            
get_tr2(traceTR_flFractionfraction);
            if( 
fraction==1.0 )
            {
                if(
owner) {
                    
forward_return(FMV_CELL, -1);
                    return 
FMRES_SUPERCEDE;
                }
            }
        }
    }
    
    
// grenade could not hit anyones eyes, cancel the check
    
forward_return(FMV_CELL, -1);
    return 
FMRES_SUPERCEDE;




All times are GMT -4. The time now is 11:17.

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