Raised This Month: $ Target: $400
 0% 

Out of bounds error in clientPrethink. Would appreciate some help.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 07-09-2012 , 13:39   Out of bounds error in clientPrethink. Would appreciate some help.
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_class_zombie>
#include <zp50_class_nemesis>
#include <zp50_ammopacks>

new g_bitAlivePlayersg_bitUserAllowed
#define MarkUserAlive(%0)       g_bitAlivePlayers |= (1 << (%0 & 31))
#define ClearUserAlive(%0)      g_bitAlivePlayers &= ~(1 << (%0 & 31))
#define IsUserAlive(%0)        g_bitAlivePlayers & (1 << (%0 & 31))

#define MarkUserAllow(%0)       g_bitUserAllowed |= (1 << (%0 & 31))
#define ClearUserAllow(%0)      g_bitUserAllowed &= ~(1 << (%0 & 31))
#define IsUserAllow(%0)        g_bitUserAllowed & (1 << (%0 & 31))

/*================================================================================
 [Constants, Offsets, Macros]
=================================================================================*/

// Plugin Version
new const PLUGIN_VERSION[] = "1.1.0 (zp50)"

// Brute Mother
new const zclass_name[] = { "Shaman" }
new const 
zclass_info[] = { "Heal teammates [E]" }
new const 
zclass_model[][] = { "bmother" }
new const 
zclass_clawmodel[][] = { "models/zombie_plague/v_bmother_hands.mdl" }
const 
zclass_health 2750
const Float:zclass_speed 0.90
const Float:zclass_gravity 1.0
const Float:zclass_knockback 1.0

/*================================================================================
 [Global Variables]
=================================================================================*/

// Player vars
new Float:g_flMaxHealth[33// zombie's max health
new g_iHealCounter[33// brute mother heal counter
new Float:g_fNextOccurance[33]
new 
healSpr

// Game vars
new g_iMotherIndex // index from the class

// Cvar pointers
new cvar_Intervalcvar_Amountcvar_Rangecvar_Counter

/*================================================================================
 [Precache and Init]
=================================================================================*/

public plugin_precache()
{
    
register_plugin("[ZP] Zombie Class: Shaman"PLUGIN_VERSION"lambda")
    
    new 
index
    g_iMotherIndex 
zp_class_zombie_register(zclass_namezclass_infozclass_healthzclass_speedzclass_gravity)
    
zp_class_zombie_register_kb(g_iMotherIndexzclass_knockback)
    for (
index 0index sizeof zclass_modelindex++)
        
zp_class_zombie_register_model(g_iMotherIndexzclass_model[index])
    for (
index 0index sizeof zclass_clawmodelindex++)
        
zp_class_zombie_register_claw(g_iMotherIndexzclass_clawmodel[index])
        
    
healSpr precache_model("sprites/healSpr.spr")
}

public 
plugin_init()
{
    
RegisterHam(Ham_Killed"player""fwd_PlayerKilled_Post"1)
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink")
    
    
cvar_Interval register_cvar("zp_mother_interval""0.5")
    
cvar_Amount register_cvar("zp_mother_amount""25")
    
cvar_Range register_cvar("zp_mother_range""145")
    
cvar_Counter register_cvar("zp_mother_counter""100")
}

public 
client_putinserver(id)
{
    
g_iHealCounter[id] = 0
    ClearUserAlive
(id)
    
ClearUserAllow(id)
}

public 
client_disconnect(id)
{
    
g_iHealCounter[id] = 0
    ClearUserAlive
(id)
    
ClearUserAllow(id)
}

/*================================================================================
 [Main Forwards]
=================================================================================*/

public zp_fw_core_spawn_post(id)
{
    if(
is_user_alive(id))
        
MarkUserAlive(id)
}

public 
fwd_PlayerKilled_Post(victimattackergib)
{
    if (!
is_user_connected(victim))
        return
    
    
ClearUserAlive(victim)
    
g_iHealCounter[victim] = 0
}

public 
fwd_PlayerPreThink(id)
{
    if (~
IsUserAllow(id) || ~IsUserAlive(id))
        return
    
    static 
Float:fGameTime
    fGameTime 
get_gametime()
    
    if (
g_fNextOccurance[id] < fGameTime)
    {
        
g_fNextOccurance[id] = fGameTime get_pcvar_float(cvar_Interval)
    
        static 
Float:originF[3]
        
pev(idpev_originoriginF)
        
        static 
Float:rangeFloat:amountvictim
        range 
get_pcvar_float(cvar_Range)
        
amount get_pcvar_float(cvar_Amount)
        
victim = -1
        
        
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginFrange)) != 0)
        {
            if (~
IsUserAlive(victim) || victim == id) continue
            
            new 
Float:currentHP
            pev
(victimpev_healthcurrentHP)
            if (
currentHP amount g_flMaxHealth[victim])
            {
                
set_pev(victimpev_healthcurrentHP amount)
                
g_iHealCounter[id]++
            }
        }
        
        while (
g_iHealCounter[id] > get_pcvar_num(cvar_Counter))
        {
            static 
Float:origin[3]
            
pev(idpev_originorigin)
            
            
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin0)
            
write_byte(TE_SPRITE)
            
engfunc(EngFunc_WriteCoord,origin[0])
            
engfunc(EngFunc_WriteCoord,origin[1])
            
engfunc(EngFunc_WriteCoord,origin[2])
            
write_short(healSpr)
            
write_byte(8)
            
write_byte(255)
            
message_end()
            
            
zp_ammopacks_set(idzp_ammopacks_get(id) + 1)
            
            
g_iHealCounter[id] -= get_pcvar_num(cvar_Counter)
        }
    }
}

public 
zp_fw_core_infect_post(idattacker)
{
    if (!
is_user_connected(id))
        return
    
    
g_iHealCounter[id] = 0
    
    
if (zp_class_nemesis_get(id))
    {
        
ClearUserAllow(id)
        return
    }
    
    
pev(idpev_healthg_flMaxHealth[id])
    
    if (
zp_class_zombie_get_current(id) == g_iMotherIndex)
    {
        
MarkUserAllow(id)
    }
    else
        
ClearUserAllow(id)
}

public 
zp_fw_core_cure_post(id)
{
    
ClearUserAllow(id)
    
ClearUserAlive(id)
    
g_iHealCounter[id] = 0

Getting an index out of bounds error on:
PHP Code:
if (currentHP amount g_flMaxHealth[victim]) 
Not sure why, but I'd appreciate the help if possible.
Y060N is offline
 



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 15:07.


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