could fix the error on line 87 by upgrading to latest version of amxx, but i'll post a fix anyways. And I put a comment where you would do the distance part, but guess I'll add that for you as well
Code:
#include <amxmodx>
#include <superheromod>
#include <fakemeta>
new const plugin[] = "SUPERHERO Hero"
new const version[] = "1.0"
new const author[] = "Random1"
#define hero_taskid 100
#define OFFSET_LINUX 5
#if cellbits == 32
#define OFFSET_TEAM 114
#else
#define OFFSET_TEAM 139
#endif
new gHeroName[] = "Hero"
new bool:gHasHero[SH_MAXSLOTS+1]
new thinkent, healamnt, healtime, healrange
//---------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin(plugin,version,author)
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("hero_level", "0")
healamnt = register_cvar("hero_healpoints", "5")
healtime = register_cvar("hero_healdelay", "1.0")
healrange = register_cvar("hero_healrange", "75.0")
// 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")
thinkent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if ( pev_valid(thinkent) )
{
set_pev(thinkent, pev_classname, "thinkloop");
set_pev(thinkent, pev_nextthink, get_gametime() + get_pcvar_float(healtime));
register_forward(FM_Think, "heal_think");
}
}
//----------------------------------------------------------------------------------------------
public heal_think(ent)
{
if ( ent != thinkent ) return FMRES_IGNORED
new wpnid, idteam, id, i, trash, Float:idorig[3], Float:playerorig[3], Float:dist
for ( id = 1; id <= SH_MAXSLOTS; id++ )
{
if ( !is_user_alive(id) || is_user_bot(id) ) continue
if ( gHasHero[id] ) {
wpnid = get_user_weapon(id,trash,trash)
idteam = ff_get_user_team(id)
pev(id, pev_origin, idorig)
if ( wpnid == CSW_KNIFE ) {
for ( i = 1; i <= SH_MAXSLOTS; i++ ) {
if ( !is_user_alive(i) || is_user_bot(i) ) continue
pev(i, pev_origin, playerorig)
dist = get_distance_f(idorig, playerorig)
if ( ff_get_user_team(i) == idteam && dist < get_pcvar_float(healrange) )
hero_heal(i)
}
}
}
}
set_pev(ent, pev_nextthink, get_gametime() + get_pcvar_float(healtime))
return FMRES_HANDLED
}
//------------------------------------------------------------------------------------
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 Beast
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasHero[id] = (hasPowers != 0)
}
//---------------------------------------------------------------------------------------
//no reason to declare this a public function
hero_heal(id)
{
//heal code
//do the code for one person since it will execute on everyone by virtue of the for loop above.
ff_set_user_health(id, get_pcvar_num(healamnt)) //just put this as an example use whatever you want
}
//get users team using fakemeta
ff_get_user_team(id)
{
if(!is_user_connected(id))
return 0;
return get_pdata_int(id, OFFSET_TEAM, OFFSET_LINUX);
}
ff_set_user_health(index, amnt)
{
if ( !pev_valid(index) ) return 0;
set_pev(index, pev_health, float(amnt));
return 1;
}
__________________
If at first you don't succeed, then skydiving isn't for you.