PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_class_zombie>
#include <zp50_class_nemesis>
#include <zp50_ammopacks>
new g_bitAlivePlayers, g_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_Interval, cvar_Amount, cvar_Range, cvar_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_name, zclass_info, zclass_health, zclass_speed, zclass_gravity)
zp_class_zombie_register_kb(g_iMotherIndex, zclass_knockback)
for (index = 0; index < sizeof zclass_model; index++)
zp_class_zombie_register_model(g_iMotherIndex, zclass_model[index])
for (index = 0; index < sizeof zclass_clawmodel; index++)
zp_class_zombie_register_claw(g_iMotherIndex, zclass_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(victim, attacker, gib)
{
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(id, pev_origin, originF)
static Float:range, Float:amount, victim
range = get_pcvar_float(cvar_Range)
amount = get_pcvar_float(cvar_Amount)
victim = -1
while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, range)) != 0)
{
if (~IsUserAlive(victim) || victim == id) continue
new Float:currentHP
pev(victim, pev_health, currentHP)
if (currentHP + amount < g_flMaxHealth[victim])
{
set_pev(victim, pev_health, currentHP + amount)
g_iHealCounter[id]++
}
}
while (g_iHealCounter[id] > get_pcvar_num(cvar_Counter))
{
static Float:origin[3]
pev(id, pev_origin, origin)
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
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(id, zp_ammopacks_get(id) + 1)
g_iHealCounter[id] -= get_pcvar_num(cvar_Counter)
}
}
}
public zp_fw_core_infect_post(id, attacker)
{
if (!is_user_connected(id))
return
g_iHealCounter[id] = 0
if (zp_class_nemesis_get(id))
{
ClearUserAllow(id)
return
}
pev(id, pev_health, g_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.