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-08-2008 , 07:50   Re: Healing help...
Reply With Quote #1

It wont work can you find a way to make it like I explained in the first post as I'm also gonna add something else into that to with the same checks...
B.A.N.G.E.R.S is offline
Xel0z
Senior Member
Join Date: Apr 2006
Location: Netherlands
Old 07-08-2008 , 12:32   Re: Healing help...
Reply With Quote #2

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.
__________________
Heroes: TESS-One Working on: Grit (Fixing bugs)

Last edited by Xel0z; 07-08-2008 at 14:24.
Xel0z is offline
Send a message via MSN to Xel0z
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 07-08-2008 , 14:19   Re: Healing help...
Reply With Quote #3

fixing what you already had in your post(with comments)
Code:
public HERO_loop()
{
 new wpnid = get_user_weapon(id)  //why did both jan itor and xel0z do read_data(2)?  that info isn't passed during the loop
//as of 1.8.0 you don't need to pass clip and ammo which is why I removed them
 
 if ( !shModActive() ) return
 for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
 //think this is where you were gettin confused(bangers), everything enclosed in this for loop will execute for each id.  Thus what you wanted is already working as you intended.
  if ( !is_user_alive(id) || !gHasHEROPower[id] ) return
  if (wpnid == CSW_KNIFE)   {  //you had forgot the if statment
   HERO_healself(id)  //pass the id to heal, since id is running thru a loop this block of code will get executed on all players anyways
  }
 }
}
//----------------------------------------------
public HERO_healself(id)
{
//heal code
//do the code for one person since it will execute on everyone by virtue of the for loop above.
}
__________________
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
Xel0z
Senior Member
Join Date: Apr 2006
Location: Netherlands
Old 07-08-2008 , 14:23   Re: Healing help...
Reply With Quote #4

Quote:
Originally Posted by G-Dog View Post
Code:
new wpnid = get_user_weapon(id)  //why did both jan itor and xel0z do read_data(2)?  that info isn't passed during the loop
//as of 1.8.0 you don't need to pass clip and ammo which is why I removed them
I actually just copied that part from jan itor's code, hehe.
__________________
Heroes: TESS-One Working on: Grit (Fixing bugs)
Xel0z is offline
Send a message via MSN to Xel0z
B.A.N.G.E.R.S
Member
Join Date: Sep 2007
Old 07-09-2008 , 02:47   Re: Healing help...
Reply With Quote #5

So what your saying G-Dog is that I can enable it to heal teammates in the heal self because i wanted to make a second ability where the hero could heal teammates when knife is out so i guess it would be easier to just do it there...

EDIT: but that would also require a range check...

SECOND EDIT: Now that I tried your code it still wont work

Code:
 
Error: Undefined symbol "id" on line 263
its this line of your script:
Code:
 
new wpnid = get_user_weapon(id)

Last edited by B.A.N.G.E.R.S; 07-09-2008 at 03:05. Reason: added some more...
B.A.N.G.E.R.S is offline
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 07-09-2008 , 03:37   Re: Healing help...
Reply With Quote #6

threw this all together kinda fast so it's untested, but this will heal self and teamates when holding knife.
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
//---------------------------------------------------------------------------------------
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")

	// 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
	
	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)
			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 ) 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 , 06:46   Re: Healing help...
Reply With Quote #7

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
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