Raised This Month: $ Target: $400
 0% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 02-11-2007 , 23:43   Run time error 4: index out of bounds
Reply With Quote #1

Giving me a run time error
Code:
L 02/06/2007 - 02:13:02: [AMXX] Displaying debug trace (plugin "zombie_swarm.amxx")
L 02/06/2007 - 02:13:02: [AMXX] Run time error 4: index out of bounds 
L 02/06/2007 - 02:13:02: [AMXX]    [0] zombie_swarm.sma::event_damage_camera (line 356)
L 02/06/2007 - 02:13:02: [AMXX] Displaying debug trace (plugin "zombie_swarm.amxx")
L 02/06/2007 - 02:13:02: [AMXX] Run time error 4: index out of bounds 
L 02/06/2007 - 02:13:02: [AMXX]    [0] zombie_swarm.sma::event_damage_lifesteal (line 386)
PHP Code:
public event_damage_camera(id)
{
    if (!
is_user_alive(id) || !is_user_connected(id)) 
        return 
PLUGIN_CONTINUE
    
    
new damage read_data(2)
    new 
AttakerWeaponAttakerPartHit
    
new attacker get_user_attacker(idAttakerWeaponAttakerPartHit)
    
    if( 
g_zombie[attacker] ) //<--- This line
    
{
        if(
AttakerWeapon == CSW_KNIFE && damage >= 55)    
        {
            new 
Float:Random_Float[3]
            for(new 
03i++) Random_Float[i] = random_float(100.0125.0)
            
Punch_View(idRandom_Float)
        }
    }    
    return 
PLUGIN_CONTINUE
}

stock Punch_View(idFloat:ViewAngle[3])
{
    
entity_set_vector(idEV_VEC_punchangleViewAngle)
}

public 
event_damage_lifesteal(id) {
    
    new 
damage read_data(2)
    new 
attacker get_user_attacker(id)
    
    if ( ! 
is_user_alive(id) || ! is_user_connected(id) )
        return 
PLUGIN_CONTINUE
    
    
new current_hp get_user_health(attacker)
    new 
max_hp get_pcvar_num(zomb_hp)
    
    
current_hp += damage
    
    
if ( g_zombie[attacker] ) { //<--- This line
        
if ( current_hp >= max_hp )
            
set_user_health(attackermax_hp)
        else
            
set_user_health(attackercurrent_hp)
    }
    return 
PLUGIN_CONTINUE


Also, is it possible to only use one function for the both of these things to make it a bit cleaner?
__________________
It's a mystery.
Mini_Midget is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-11-2007 , 23:49   Re: Run time error 4: index out of bounds
Reply With Quote #2

you should check the index of the attacker which get_user_attacker returned.
because if an entity attack the user, also trigger the damage event, and the entity's index may out of your array's bounds
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 02-12-2007 , 00:54   Re: Run time error 4: index out of bounds
Reply With Quote #3

I have checked it but its in the plugin_init
PHP Code:
    register_event("Damage""event_damage_camera""be""2!0","3=0","4!0")
    
register_event("Damage""event_damage_lifesteal""be""2!0","3=0","4!0"
__________________
It's a mystery.
Mini_Midget is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-12-2007 , 01:04   Re: Run time error 4: index out of bounds
Reply With Quote #4

that can't handle all the situation.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 02-12-2007 , 01:13   Re: Run time error 4: index out of bounds
Reply With Quote #5

oh..
Then how do I check the index (attacker) if its an entity or not not via plugin_init?
__________________
It's a mystery.
Mini_Midget is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-12-2007 , 01:16   Re: Run time error 4: index out of bounds
Reply With Quote #6

if (attacker > sizeof g_zombie) return

i wonder what is your g_zombie like
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang 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 00:36.


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