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 , 06:33   Healing help...
Reply With Quote #1

Hello I'm making a hero that can heal when knife is out but after like 10 different test with different code every time it didnt work if its posible I would like to have something like this:

PHP Code:
public HERO_loop()
{
 new 
clipammowpnid get_user_weapon(id,clip,ammo)
 
 if (!
shModActive()) return
 for ( new 
id 1id <= SH_MAXSLOTSid++ ) {
  if ( !
is_user_alive(id) || !gHasHEROPower[id] ) return
  (
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.
   
HERO_healself
  
}
 }
}
//----------------------------------------------
public HERO_healself()
{
//heal code

What I mean is that there is a loop then if all the checks in the loop is true it reads from the HERO_healself where the heal code is added...

+ karma to the one who gives me this (if its working)
B.A.N.G.E.R.S is offline
Dr. Jan Itor
Veteran Member
Join Date: Mar 2008
Location: there.
Old 07-08-2008 , 06:43   Re: Healing help...
Reply With Quote #2

try using
Code:
public hero_loop()
{
    new wpnid = read_data(2)
  
 if ( wpnid == CSW_KNIFE )
    if (!shModActive()) return
    for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
        if (  HasHero[id] && is_user_alive(id)  )   {
            // 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] )
        }
    }
}
__________________
Dr. Jan Itor is offline
B.A.N.G.E.R.S
Member
Join Date: Sep 2007
Old 07-08-2008 , 07:50   Re: Healing help...
Reply With Quote #3

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

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

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

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

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
B.A.N.G.E.R.S
Member
Join Date: Sep 2007
Old 07-09-2008 , 05:08   Re: Healing help...
Reply With Quote #8

Thank you I'll try it out later as im busy right now... + Karma to you if it works!
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