AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Healing always to 100 hp no matter what I change. Need 255. (https://forums.alliedmods.net/showthread.php?t=98873)

cikjam 07-30-2009 09:55

Healing always to 100 hp no matter what I change. Need 255.
 
Hello,

Problem is with blockmaker heal block:

If I have 255 hp and I go on heal block it goes back 100, I tried everything, I even changed it all to 255 to see if it will heal to 255, still 100.

Code:

actionHeal(id)
{
    if (halflife_time() >= gfNextHealTime[id])
    {
        new szPlayerName[32];
            get_user_name(id, szPlayerName, 32);
        new hp = get_user_health(id);
        new amount = floatround(get_cvar_float("bm_healamount"), floatround_floor);
        new sum = (hp + amount);
       
        if (sum < 100)
        {
            set_user_health(id, sum);
        }
        else
        {
            set_user_health(id, 100);
        }
       
        gfNextHealTime[id] = halflife_time() + 0.5;
    }
}

I need it so if you have less then 100hp it will heal to 100. If you have like 101 it will heal to 255.

Xellath 07-30-2009 10:14

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Just add a check:
PHP Code:

if ( get_user_healthid ) > 101 )
{
    return 
PLUGIN_HANDLED;



Bugsy 07-30-2009 10:17

Re: Healing always to 100 hp no matter what I change. Need 255.
 
PHP Code:

actionHeal(id)
{
    if ( 
halflife_time() >= gfNextHealTime[id] )
    {
        static 
iHealthiHealth get_user_healthid );

        if ( ( 
iHealth == 100 ) || ( iHealth == 255 ) )
            return 
PLUGIN_HANDLED;

        
set_user_healthid , ( iHealth 100 ) ? 100 255 );
    
        
gfNextHealTime[id] = halflife_time() + 0.5;
    }

    return 
PLUGIN_HANDLED;



Xellath 07-30-2009 10:24

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Wait, now I am confused. Do you want the block to heal to 255 if the user has more then 100 hp, or just stop the users health from going down to 100 if they have more then 100?

Bugsy 07-30-2009 10:25

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Quote:

I need it so if you have less then 100hp it will heal to 100. If you have like 101 it will heal to 255.

LaineN 07-30-2009 10:29

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Code:
actionHeal(id) {     if ( !( halflife_time() >= gfNextHealTime[id] ) ) return PLUGIN_HANDLED;         new amount = floatround(get_cvar_float("bm_healamount"), floatround_floor);     new new_health = (get_user_health(id) + amount);         if ( new_health > 100 ) return PLUGIN_HANDLED;         set_user_health(id, new_health);         gfNextHealTime[id] = halflife_time() + 0.5;         return PLUGIN_HANDLED; }

cikjam 07-30-2009 23:59

Re: Healing always to 100 hp no matter what I change. Need 255.
 
tested them both, they both go back to 100

Bugsy 07-31-2009 00:12

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Quote:

Originally Posted by cikjam (Post 886201)
tested them both, they both go back to 100

I just tested it too and it works fine. Must be something else in your code or another plugin that is causing the problem.

In chat, do the following:

say "blah" - nothing should happen
now injure yourself to any degree besides killing yourself. use a grenade on yourself or something
say "blah" - your health should now be 100
say "blah" - nothing should happen, health still at 100
say "hp" - your health should now go to 110
say "blah" - your health should now go to 255
say "blah" - nothing should happen, health still at 255

PHP Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "bugsy"

new FloatgfNextHealTime[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd"say hp" "hp" );
    
    
register_clcmd"say blah" "blah" );
}

public 
hp(id)
{
    
set_user_healthid get_user_healthid ) + 10 );
}

public 
blahid )
{
    if ( 
get_gametime() >= gfNextHealTime[id] )
    {
        static 
iHealthiHealth get_user_healthid );
    
        if ( ( 
iHealth == 100 ) || ( iHealth == 255 ) )
            return 
PLUGIN_HANDLED;
    
        
set_user_healthid , ( iHealth 100 ) ? 100 255 );
    
        
gfNextHealTime[id] = get_gametime() + 0.5;
    }
    
    return 
PLUGIN_HANDLED;



cikjam 07-31-2009 00:41

Re: Healing always to 100 hp no matter what I change. Need 255.
 
I test that blah thing, it works like you said, but when i put the actionheal in bm it doesnt work'

maybe u can try in bm, and see if works

EDIT: Btw, wheres the bm_healamount in it

Exolent[jNr] 07-31-2009 00:54

Re: Healing always to 100 hp no matter what I change. Need 255.
 
Code:
actionHeal(id) {     if ( !( halflife_time() >= gfNextHealTime[id] ) ) return PLUGIN_HANDLED;         new iHealth = get_user_health( id );     if( iHealth >= 255 || iHealth == 100 ) return PLUGIN_HANDLED;         if( iHealth < 100 )     {         iHealth = min( 100, iHealth + floatround(get_cvar_float("bm_healamount"), floatround_floor) );     }     else //if( iHealth > 100 )     {         iHealth++;         // no need to check for 255 maximum, since it is only by 1     }         set_user_health(id, iHealth);         gfNextHealTime[id] = halflife_time() + 0.5;         return PLUGIN_HANDLED; }


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

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