Hi!
I have been working on a hero that is supposed to get healed when he is getting hit, so pretty much the opposite from dracula!
Code:
// Mutant!
/* CVARS - copy and paste to shconfig.cfg
//Mutant
mutant_level 1
mutant_pctperlev 0.01 //chance of getting healed when being hit
*/
#include <amxmod>
#include <fun>
#include <superheromod>
// GLOBAL VARIABLES
new gHeroName[]="Mutant"
new bool:HasMutant[SH_MAXSLOTS+1]
new PlayersLevel2[SH_MAXSLOTS+1]
new PlayersMaxHealth2[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
register_plugin("SUPERHERO Mutant","2.0","Mutants will rule the world!")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("mutant_level", "1" )
register_cvar("mutant_pctperlev", "0.01" )
shCreateHero(gHeroName, "Damage Absorbtion", "Gain HP by getting shot by people - More HP per level!", false, "mutant_level" )
// init.
register_srvcmd("mutant_init", "mutant_init")
shRegHeroInit(gHeroName, "mutant_init")
// LEVELS
register_srvcmd("mutant_levels", "mutant_levels")
shRegLevels(gHeroName, "mutant_levels")
// GET MORE ENERGY!
register_event("Damage", "mutant_damage", "b", "2!0")
// Makes superhero tell mutant a players max health
register_srvcmd("mutant_maxhealth", "mutant_maxhealth")
shRegMaxHealth(gHeroName, "mutant_maxhealth")
}
//----------------------------------------------------------------------------------------------
public mutant_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 mutant skills
read_argv(2,temp,5)
new hasPowers=str_to_num(temp)
HasMutant[id] = (hasPowers!=0)
}
//----------------------------------------------------------------------------------------------
public mutant_levels()
{
new id[5]
new lev[5]
read_argv(1, id, 4)
read_argv(2, lev, 4)
PlayersLevel2[str_to_num(id)] = str_to_num(lev)
}
//----------------------------------------------------------------------------------------------
public mutant_damage(id)
{
if ( !shModActive() || !is_user_connected(id) ) return PLUGIN_CONTINUE
new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return PLUGIN_CONTINUE
if ( HasMutant[id] && is_user_alive(attacker) && id != attacker ) {
// Add some HP back!
//new giveHPs2 = floatround(damage * get_pcvar_float(CvarMultiplier2) * PlayersLevel2[attacker])
new giveHPs2 = floatround( ( PlayersLevel2[id] * get_cvar_float("mutant_pctperlev") ) * damage )
if (giveHPs2 > 0)
{
new alphanum = damage * 2
if (alphanum > 200)
alphanum = 200
else if (alphanum < 40)
alphanum = 40
setScreenFlash(victim, 255, 10, 10, 10, alphanum) //Red Screen Flash
shAddHPs(attacker, giveHPs2, PlayersMaxHealth2[attacker])
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mutant_maxhealth()
{
new id[6]
new health[9]
read_argv(1, id, 5)
read_argv(2, health, 8)
PlayersMaxHealth2[str_to_num(id)] = str_to_num(health)
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
HasMutant[id] = false
}
//----------------------------------------------------------------------------------------------
But it dosn't work. I suspect this will heal the enemy player instead that hurts me but I want it to heal me instead when a enemy player hurts me xD
Any help would be greatly appreciated!