Raised This Month: $ Target: $400
 0% 

Healing help...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
B.A.N.G.E.R.S
Member
Join Date: Sep 2007
Old 07-09-2008 , 06:46   Re: Healing help...
Reply With Quote #1

Okay I added it to the code and got one error:
Code:
Error: Number of arguments does not match definition on line 87
This is the part:
Code:
 
public heal_think(ent)
{
 if ( ent != thinkent ) return FMRES_IGNORED
 new idteam, id, i
 new wpnid = get_user_weapon(id) //THIS IS LINE 87
 
 for ( id = 1; id <= SH_MAXSLOTS; id++ )
 {
  if ( !is_user_alive(id) || is_user_bot(id) ) continue
  if ( gHasHEROPower[id] ) {
   idteam = ff_get_user_team(id)
   if ( wpnid == CSW_KNIFE ) {
    for ( i = 1; i <= SH_MAXSLOTS; i++ )
    //if you want to do a distance check as well this is where you'de do it
     if ( ff_get_user_team(i) == idteam ) medic_heal(i) 
   }
  } 
 }
 set_pev(ent, pev_nextthink, get_gametime() + get_pcvar_float(healtime))
 
 return FMRES_HANDLED
}
And I also noticed you didnt put a range check into the hero...
B.A.N.G.E.R.S is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 07-09-2008 , 09:52   Re: Healing help...
Reply With Quote #2

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.
G-Dog is offline
Send a message via AIM to G-Dog
B.A.N.G.E.R.S
Member
Join Date: Sep 2007
Old 07-09-2008 , 11:33   Re: Healing help...
Reply With Quote #3

Now it compiles but when i test it neither of the healing codes work...
B.A.N.G.E.R.S is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:51.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode