PHP Code:
// Heavy
/* CVARS - copy and paste to shconfig.cfg
//Heavy
heavy_level 25
heavy_health 500
heavy_armor 1000
heavy_m249speed 670
heavy_mult 4.0
heavy_healpoints 25
*/
/*
*
*
* Heavy with a minigun from TF2
*/
#include <superheromod>
new gHeroID
new const gHeroName[]="Heavy"
new bool:gHasHeavy[SH_MAXSLOTS+1]
new gPcvarMult, gPcvarHealPoints
new const g_v_model[] = "models/shmod/heavy_v_m249.mdl"
new const g_p_model[] = "models/shmod/heavy_p_m249.mdl"
public plugin_init()
{
register_plugin("SUPERHERO Heavy", "1.0", "Lyserinc")
new pcvarLevel = register_cvar("heavy_level", "25")
new pcvarHealth = register_cvar("heavy_health", "500")
new pcvarArmor = register_cvar("heavy_armor", "1000")
new pcvarSpeed = register_cvar("heavy_m249speed", "670")
gPcvarMult = register_cvar("heavy_mult", "4.0")
gPcvarHealPoints = register_cvar("heavy_healpoints", "25")
gHeroID = sh_create_hero(gHeroName, pcvarLevel)
sh_set_hero_info(gHeroID, "Heavy Machinery", "HP/AP/Strong m249")
sh_set_hero_hpap(gHeroID, pcvarHealth, pcvarArmor)
sh_set_hero_speed(gHeroID, pcvarSpeed, {CSW_M249})
set_task(1.0, "heavy_loop", _, _, _, "b")
}
public sh_hero_init(id, heroID, mode)
{
if (gHeroID != heroID) return
switch(mode)
{
case SH_HERO_ADD:
{
gHasHeavy[id] = true
switchmodel(id)
}
case SH_HERO_DROP:
{
gHasHeavy[id] = false
}
}
}
public plugin_precache()
{
precache_model(g_v_model)
precache_model(g_p_model)
}
public sh_client_spawn(id)
{
if (sh_is_active() && gHasHeavy[id] && is_user_alive(id))
{
sh_give_weapon(id, CSW_M249)
}
}
public heavy_loop()
{
if (!sh_is_active()) return
static players[SH_MAXSLOTS], playerCount, player, i
get_players(players, playerCount, "ah")
for (i = 0; i < playerCount; i++)
{
player = players[i]
if (gHasHeavy[player])
{
sh_add_hp(player, get_pcvar_num(gPcvarHealPoints))
}
}
}
public client_damage(attacker, victim, damage, wpnindex, hitplace)
{
if (!sh_is_active()) return
if (!is_user_alive(victim) || !is_user_connected(attacker)) return
if (gHasHeavy[attacker] && wpnindex == CSW_M249)
{
new headshot = hitplace == 1 ? 1 : 0
new extraDamage = floatround(damage * get_pcvar_float(gPcvarMult) - damage)
if (extraDamage > 0) sh_extra_damage(victim, attacker, extraDamage, "m249", headshot)
}
}
public weapon_change(id)
{
if (!sh_is_active() || !gHasHeavy[id]) return
if (read_data(2) == CSW_M249) switchmodel(id)
}
switchmodel(id)
{
if (!sh_is_active() || !is_user_alive(id) || !gHasHeavy[id]) return
new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)
if (wpnid == CSW_M249)
{
set_pev(id, pev_viewmodel2, g_v_model)
set_pev(id, pev_weaponmodel2, g_p_model)
}
}
I made some minor mistakes in my previous code.
You should put the models in models/shmod and name them to:
heavy_v_m249.mdl and heavy_p_m249.mdl
__________________