AlliedModders

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

dias 11-01-2011 08:28

[Help] index out of bounds
 
Someone help me to solve this problem :(
Code:

L 11/01/2011 - 19:22:05: [AMXX] Run time error 4: index out of bounds
L 11/01/2011 - 19:22:05: [AMXX]    [0] bio_zclass_banshee.sma::Forward_AddToFullPack_Post (line 651)
L 11/01/2011 - 19:22:05: [AMXX] Displaying debug trace (plugin "bio_zclass_banshee.amx

Here is code
PHP Code:

new g_iConfusing[33], g_iEntFake[33]
new 
g_confusing[33]

public 
Forward_AddToFullPack_Post(es_handledinteenthosthostflagsplayerpSet)
{
    
// neu host ko con song thi bo qua
    
if (!is_user_alive(host))
        return 
FMRES_IGNORED
        
    
if(!g_confusing[host] || !g_iConfusing[host])
        return 
FMRES_IGNORED
    
    
// neu host ko bi dinh bomb hc thang attacker da chet
    
static iAttacker
    iAttacker 
g_iConfusing[host]
    if (!
iAttacker || iAttacker == host || !is_user_alive(iAttacker))
        return 
FMRES_IGNORED
        
    
// neu ent chinh la thang nem bomb
    
if ((ent 32) && is_user_zombie(ent))
    {
            
// an? thang do'
            
set_es(es_handledES_RenderModekRenderTransAdd)
            
set_es(es_handledES_RenderAmt0.0)
            
            
// tao ent fake cho attacker neu chua co
            
new iEntFake find_ent_by_owner(-1CLASSNAME_FAKE_PLAYERent)
            if(!
iEntFake || !pev_valid(ent))
            {
                
iEntFake create_fake_player(ent)
            }
            
            
g_iEntFake[ent] = iEntFake
    
}
    
    
// neu ent la fake player cua attack
    
if (ent == g_iEntFake[ent]) // HERE IS 651 LINE
    
{
        
// show hang' cho thang victim xem
        
set_es(es_handledES_RenderModekRenderNormal)
        
set_es(es_handledES_RenderAmt255.0)
        
        
// set model cua host cho ent fake
        
set_es(es_handledES_ModelIndexpev(hostpev_modelindex))
    }
    
    return 
FMRES_IGNORED


- I still check = "is_valid_ent" but still got error

yokomo 11-01-2011 10:02

Re: [Help] index out of bounds
 
PHP Code:

#define is_user_valid(%1) (1 <= %1 <= g_maxplayers) 

Use get_maxplayers() instead of hard coding 32..

dias 11-01-2011 10:02

Re: [Help] index out of bounds
 
PHP Code:

    if (ent == g_iEntFake[ent]) // HERE IS 651 LINE 

- Not that :(

fysiks 11-01-2011 16:34

Re: [Help] index out of bounds
 
ent is obviously greater than 32. You need to handle that case and not index an array if it's larget than 32.

dias 11-01-2011 19:16

Re: [Help] index out of bounds
 
PHP Code:

g_iEntFake[id] = iEntFake 

- This is ent of id, id only 1 ~ 32 ?


All times are GMT -4. The time now is 14:24.

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