Zombi Class problem(index out of bounds)
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 zClassId, DisarmTime, DisarmChance, ScreenFadeEffects, SpR_Paralyzed
new bool: CantFire[ 33 ] = 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_NAME, D_ZOMBIE_DESC)
if(zClassId != -1)
{
set_class_data(zClassId, DATA_HEALTH, 370.0)
set_class_data(zClassId, DATA_SPEED, 266.0)
set_class_data(zClassId, DATA_GRAVITY, 0.75)
set_class_data(zClassId, DATA_HITSPEED, 0.69)
set_class_pmodel(zClassId, D_PLAYER_MODEL)
set_class_wmodel(zClassId, D_CLAWS)
}
}
public plugin_precache( )
{
SpR_Paralyzed = precache_model( "sprites/paralyzed.spr" )
precache_model(PMODEL)
precache_model(D_CLAWS)
}
public Event_Damage( victim )
{
new id
id = get_user_attacker( victim )
if( get_user_class( victim ) != zClassId
|| !is_user_zombie( victim ) )
return PLUGIN_CONTINUE;
new Rand = random_num( 1, 100 )
if( Rand > 0 && Rand <= get_pcvar_num( DisarmChance ) )
{
CantFire[ id ] = true
Effects( id )
set_task( get_pcvar_float( DisarmTime ), "StopDisarmCc", id )
}
return PLUGIN_CONTINUE;
}
public client_PreThink( Player )
{
if( !CantFire[ Player ] )
return PLUGIN_CONTINUE;
entity_set_int( Player, EV_INT_button, entity_get_int( Player, EV_INT_button ) & ~IN_ATTACK ) // Player will scared :D
return PLUGIN_CONTINUE;
}
public Effects( id )
{
message_begin( MSG_ONE_UNRELIABLE, ScreenFadeEffects,.player = id )
write_short( ( 1<<10 ) )
write_short( 0 )
write_short( 0x0000 )
write_byte( 255 ) // Red color
write_byte( 0 ) // G
write_byte( 0 ) // B
write_byte( 255 )
message_end( )
new Float: HumanOrigin[ 3 ]
entity_get_vector( id, EV_VEC_origin, HumanOrigin )
engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, HumanOrigin, 0)
write_byte( TE_SPRITETRAIL )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 0 ] )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 1 ] )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 2 ] )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 0 ] )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 1 ] )
engfunc( EngFunc_WriteCoord, HumanOrigin[ 2 ] + 30 )
write_short( SpR_Paralyzed )
write_byte( 3 )
write_byte( 30 )
write_byte( 10 )
write_byte( 45 )
write_byte( 40 )
message_end( )
}
public StopDisarmCc( id )
{
CantFire[ id ] = 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(id, pev_flags)
if( Flags & FL_WATERJUMP || pev(id, pev_waterlevel) >= 2 || !(get_pdata_int(id, 246) & 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(id, 251) < 500 && ++_gJumpCount[id] <= get_pcvar_num(cvar_multi_jump_amount))
{
new Float:fVelocity[3]
pev(id, pev_velocity, fVelocity)
fVelocity[2] = 268.328157
set_pev(id, pev_velocity, fVelocity)
return HAM_HANDLED
}
}
}
return HAM_IGNORED
}
Problem is there:
PHP Code:
public Event_Damage( victim )
{
new id
id = get_user_attacker( victim )
if( get_user_class( victim ) != zClassId
|| !is_user_zombie( victim ) )
return PLUGIN_CONTINUE;
new Rand = random_num( 1, 100 )
if( Rand > 0 && Rand <= get_pcvar_num( DisarmChance ) )
{
CantFire[ id ] = true
Effects( id )
set_task( get_pcvar_float( DisarmTime ), "StopDisarmCc", id )
}
return PLUGIN_CONTINUE;
}
and line 66 is
Can someone help me to solve this?
|