Code:
#include <amxmodx>
#include <superheromod>
//Global Variables
new gHeroName[]="HERO"
new bool:HasHero[SH_MAXSLOTS+1]
new gPlayerMaxHealth[SH_MAXSLOTS+1]
new gHealPoints
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO HERO","1.0","AUTHOR")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("HERO_level", "4" )
register_cvar("HERO_healpoints", "15" )
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Abilities", "Description", false, "HERO_level" )
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
register_srvcmd("HERO_init", "HERO_init")
shRegHeroInit(gHeroName, "HERO_init")
// HEAL LOOP
set_task(1.0,"HERO_loop",0,"",0,"b" )
//Makes it tell players max health
register_srvcmd("HERO_maxhealth", "HERO_maxhealth")
shRegMaxHealth(gHeroName, "HERO_maxhealth" )
gHealPoints = get_cvar_num("HERO_healpoints")
}
public HERO_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id=str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has HERO skills
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gPlayerMaxHealth[id] = 100
HasHero[id] = (hasPowers!=0)
}
public HERO_loop()
{
new wpnid = get_user_weapon(id)
if (!shModActive()) return
for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
if ( HasHero[id] && is_user_alive(id) && wpnid == CSW_KNIFE ) {
// Let the server add the hps back since the # of max hps is controlled by it
// I.E. Superman has more than 100 hps etc.
shAddHPs(id, gHealPoints, gPlayerMaxHealth[id] )
}
}
}
public HERO_maxhealth()
{
new id[6]
new health[9]
read_argv(1,id,5)
read_argv(2,health,8)
gPlayerMaxHealth[str_to_num(id)] = str_to_num(health)
}
@Dr. Jan Itor: You should ofc assign values to gHealPoints and gPlayerMaxHealth.. You were missing an opening bracer after the knife check. Also, you checked it too soon.