Raised This Month: $ Target: $400
 0% 

Zombi Class problem(index out of bounds)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 11-26-2014 , 15:01   Zombi Class problem(index out of bounds)
Reply With Quote #1

I use this class but give me this error:

Run time error 4: index out of bounds
Event_Damage (line 66)

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

#define D_ZOMBIE_NAME "Paralyzer class"
#define D_ZOMBIE_DESC "auto-paralyze and 2x jumps"
#define D_PLAYER_MODEL "paralizer_bio"
#define D_CLAWS "models/v_paralizer_bio.mdl"
#define PMODEL "models/player/paralizer_bio/paralizer_bio.mdl"

new zClassIdDisarmTimeDisarmChanceScreenFadeEffectsSpR_Paralyzed
new boolCantFire33 ] = false;

new 
_gJumpCount[33]
new 
cvar_multi_jump_amount

public plugin_init() 
{
    
register_plugin("ZP CLASS : Paralizer Zombie""1.1""BboY GruN")
    
    
register_event("Damage""Event_Damage""b""2!0""3=0""4!0")

        
RegisterHam(Ham_Player_Jump"player""fw_PlayerJump"0)
    
    
DisarmChance register_cvar("chance_to_disarm""4" )
    
    
DisarmTime register_cvar("disarm_Time""3.0" // How much time the Human will stay disarm

        
cvar_multi_jump_amount register_cvar("zp_multi_jump_amount""1")
    
    
ScreenFadeEffects =     get_user_msgid"ScreenFade" )

        
zClassId register_class(D_ZOMBIE_NAMED_ZOMBIE_DESC)
 
        if(
zClassId != -1)
        {
                
set_class_data(zClassIdDATA_HEALTH370.0)
                
set_class_data(zClassIdDATA_SPEED266.0)
                
set_class_data(zClassIdDATA_GRAVITY0.75)
                
set_class_data(zClassIdDATA_HITSPEED0.69)
                
set_class_pmodel(zClassIdD_PLAYER_MODEL)
                
set_class_wmodel(zClassIdD_CLAWS)
                }
}

public 
plugin_precache( )
{
    
SpR_Paralyzed precache_model"sprites/paralyzed.spr" )
        
precache_model(PMODEL)
    
precache_model(D_CLAWS)
}

public 
Event_Damagevictim )
{
    new 
id
    id 
get_user_attackervictim )
    if( 
get_user_classvictim ) != zClassId 
    
|| !is_user_zombievictim ) )
        return 
PLUGIN_CONTINUE;
    
    new 
Rand random_num1100 )
    if( 
Rand && Rand <= get_pcvar_numDisarmChance ) ) 
    {
        
CantFireid ] = true
        Effects
id )
        
set_taskget_pcvar_floatDisarmTime ), "StopDisarmCc"id )
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
client_PreThinkPlayer )
{    
    if( !
CantFirePlayer ] )
        return 
PLUGIN_CONTINUE;
    
entity_set_intPlayerEV_INT_buttonentity_get_intPlayerEV_INT_button ) & ~IN_ATTACK // Player will scared :D
    
return PLUGIN_CONTINUE;
}

public 
Effectsid )
{
    
message_beginMSG_ONE_UNRELIABLEScreenFadeEffects,.player id )
    
write_short( ( 1<<10 ) )
    
write_short)
    
write_short0x0000 )
    
write_byte255 // Red color 
    
write_byte// G
    
write_byte// B
    
write_byte255 )
    
message_end( )
    
    new 
FloatHumanOrigin]
    
entity_get_vectoridEV_VEC_originHumanOrigin )
    
engfuncEngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYHumanOrigin0)
    
write_byteTE_SPRITETRAIL )    
    
engfuncEngFunc_WriteCoordHumanOrigin] )
    
engfuncEngFunc_WriteCoordHumanOrigin] )
    
engfuncEngFunc_WriteCoordHumanOrigin] )
    
engfuncEngFunc_WriteCoordHumanOrigin] )
    
engfuncEngFunc_WriteCoordHumanOrigin] )
    
engfuncEngFunc_WriteCoordHumanOrigin] + 30 )
    
write_shortSpR_Paralyzed 
    
write_byte
    
write_byte30 )
    
write_byte10 
    
write_byte45 )
    
write_byte40 )
    
message_end( )
}

public 
StopDisarmCcid )
{
    
CantFireid ] = false
}

public 
fw_PlayerJump(id
{
        if(!
is_user_alive(id) || !is_user_zombie(id))
    {
        return 
HAM_SUPERCEDE
    
}

    if(
is_user_alive(id) && get_user_class(id) == zClassId
    {
        new 
Flags pev(idpev_flags)
        
        if( 
Flags FL_WATERJUMP || pev(idpev_waterlevel) >= || !(get_pdata_int(id246) & IN_JUMP) )
        {
            return 
HAM_IGNORED
        
}
        if(
Flags FL_ONGROUND
        {
            
_gJumpCount[id] = 0
            
            
return HAM_IGNORED
        
}
        if(
get_pcvar_num(cvar_multi_jump_amount)) 
        {
            if( 
get_pdata_float(id251) < 500 && ++_gJumpCount[id] <= get_pcvar_num(cvar_multi_jump_amount)) 
            {
                new 
Float:fVelocity[3]
                
pev(idpev_velocityfVelocity)
                
fVelocity[2] = 268.328157
                set_pev
(idpev_velocityfVelocity)
                
                return 
HAM_HANDLED
            
}
        }
    }
    return 
HAM_IGNORED

Problem is there:
PHP Code:
public Event_Damagevictim )
{
    new 
id
    id 
get_user_attackervictim )
    if( 
get_user_classvictim ) != zClassId 
    
|| !is_user_zombievictim ) )
        return 
PLUGIN_CONTINUE;
    
    new 
Rand random_num1100 )
    if( 
Rand && Rand <= get_pcvar_numDisarmChance ) ) 
    {
        
CantFireid ] = true
        Effects
id )
        
set_taskget_pcvar_floatDisarmTime ), "StopDisarmCc"id )
    }
    
    return 
PLUGIN_CONTINUE;

and line 66 is
PHP Code:
CantFireid ] = true 
Can someone help me to solve this?
Krtola is offline
Send a message via Skype™ to Krtola
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-26-2014 , 16:14   Re: Zombi Class problem(index out of bounds)
Reply With Quote #2

Either check is_user_connected or 1<=id<=maxplayer
RateX is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 11-26-2014 , 19:29   Re: Zombi Class problem(index out of bounds)
Reply With Quote #3

Something like this? ( do not know how to do it 1<=id<=maxplayer )

PHP Code:
public Event_Damagevictim )
{
    new 
id
    id 
get_user_attackervictim )
    if( 
get_user_classvictim ) != zClassId 
    
|| !is_user_zombievictim ) )
        return 
PLUGIN_CONTINUE;
    
    new 
Rand random_num1100 )
    if( 
Rand && Rand <= get_pcvar_numDisarmChance ) && is_user_connected(id) ) 
    {
        
CantFireid ] = true
        Effects
id )
        
set_taskget_pcvar_floatDisarmTime ), "StopDisarmCc"id )
    }
    
    return 
PLUGIN_CONTINUE;


Last edited by Krtola; 11-26-2014 at 19:31.
Krtola is offline
Send a message via Skype™ to Krtola
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-26-2014 , 22:40   Re: Zombi Class problem(index out of bounds)
Reply With Quote #4

Yes, like that, though I prefer doing the check as soon as id is assigned to a value, so the plugin doesn't have to do unnecessary calculation, like:
PHP Code:
id get_user_attacker(victim)
if(
get_user_class(victim) != zClassId 
    
|| !is_user_zombie(victim
    || !
is_user_connected(id))
        return 
PLUGIN_CONTINUE 
And for the other method, here's how:
PHP Code:
g_maxplayer get_maxplayers()
if(!(
1<=id<=g_maxplayer))
        return 
PLUGIN_CONTINUE 

Last edited by RateX; 11-26-2014 at 22:40.
RateX is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 11-27-2014 , 04:12   Re: Zombi Class problem(index out of bounds)
Reply With Quote #5

Ok,what I did:

PHP Code:
public Event_Damagevictim )
{
    new 
id
    id 
get_user_attackervictim )
    if( 
get_user_classvictim ) != zClassId 
    
|| !is_user_zombievictim 
        || !
is_user_connectedid ) )
        return 
PLUGIN_CONTINUE;

        if(!(
1<=id<=g_maxplayer))
        return 
PLUGIN_CONTINUE
    
    
new Rand random_num1100 )
    if( 
Rand && Rand <= get_pcvar_numDisarmChance ) ) 
    {
        
CantFireid ] = true
        Effects
id )
        
set_taskget_pcvar_floatDisarmTime ), "StopDisarmCc"id )
    }
    
    return 
PLUGIN_CONTINUE;

Do I need to write here in -public Event_Damage-?
PHP Code:
if(!(1<=id<=g_maxplayer))
        return 
PLUGIN_CONTINUE 

Last edited by Krtola; 11-27-2014 at 04:13.
Krtola is offline
Send a message via Skype™ to Krtola
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 11-27-2014 , 04:24   Re: Zombi Class problem(index out of bounds)
Reply With Quote #6

Nope, as I said you can choose any of them, and having both is just a waste of resource.
RateX is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 11-27-2014 , 04:39   Re: Zombi Class problem(index out of bounds)
Reply With Quote #7

Quote:
Originally Posted by RateX View Post
Nope, as I said you can choose any of them, and having both is just a waste of resource.
Ok,I get it now.
Thank you ;)
Krtola is offline
Send a message via Skype™ to Krtola
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 17:32.


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