AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Last Problem! =] (https://forums.alliedmods.net/showthread.php?t=94483)

malec321 06-11-2009 19:37

[HELP] Last Problem! =]
 
Code:

        if (sum < 100)
        {
            set_user_health(id, sum);
        }
            else
        {
            set_user_health(id, 100);
        }
            gfNextHealTime[id] = halflife_time() + 0.5;


How can you make it so when you touch the heal block n u got over 100 hp it doesnt just set it to 100 again.


And I have a 2nd block called SuperHeal making it go from 0-220 HP

but when i go in it, it just sets it down to 100 please help!

Bugsy 06-11-2009 19:39

Re: [HELP] Last Problem! =]
 
Quote:

Originally Posted by malec321 (Post 846785)
Code:

        if (sum < 100)
        {
            set_user_health(id, sum);
        }
            else
        {
            set_user_health(id, 100);
        }
            gfNextHealTime[id] = halflife_time() + 0.5;


How can you make it so when you touch the heal block n u got over 100 hp it doesnt just set it to 100 again.


And I have a 2nd block called SuperHeal making it go from 0-220 HP

but when i go in it, it just sets it down to 100 please help!

Where do you want it capped off at?

set_user_health(id, get_user_health(id) + 100 ); ??

malec321 06-11-2009 19:44

Re: [HELP] Last Problem! =]
 
I want it capped at 255



Here

Super Heal Code (Up to 220 HP) dont set it back to 220 or 100 if u have 255 HP:
Code:

actionSHEAL(id)
{
    if (halflife_time() >= gfNextSHEALTime[id])
    {
        new hp = get_user_health(id);
        new amount = floatround(get_cvar_float("bm_shealamount"), 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;
    }
}

Normal Heal (Go up to 100 HP) but dont let it go down back to 100 if u got 255 HP:

Code:

actionHeal(id)
{
    if (halflife_time() >= gfNextHealTime[id])
    {
        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;
    }
}


Bugsy 06-11-2009 19:50

Re: [HELP] Last Problem! =]
 
PHP Code:

if (halflife_time() >= gfNextHealTime[id])
{
    new 
amount floatround(get_cvar_float("bm_healamount"), floatround_floor);
   
    
set_user_healthid clampget_user_healthid ) + clampamount 100 ) , 255 ) );
    
gfNextHealTime[id] = halflife_time() + 0.5;



malec321 06-11-2009 19:55

Re: [HELP] Last Problem! =]
 
if (halflife_time() >= gfNextHealTime[id])
{
new
amount = floatround(get_cvar_float("bm_healamount"), floatround_floor);

set_user_health( id , clamp( get_user_health( id ) + clamp( amount , 100 ) , 0 , 255 ) );
gfNextHealTime[id] = halflife_time() + 0.5;
}

And if its SHEAL it would be:

if (halflife_time() >= gfNextHealTime[id])
{
new
amount = floatround(get_cvar_float("bm_shealamount"), floatround_floor);

set_user_health( id , clamp( get_user_health( id ) + clamp( amount , 200 ) , 0 , 255 ) );
gfNextHealTime[id] = halflife_time() + 0.5;
}


rite?

Bugsy 06-11-2009 19:58

Re: [HELP] Last Problem! =]
 
shouldnt sheal be 220 and not 200 or is the above a typo

malec321 06-11-2009 19:59

Re: [HELP] Last Problem! =]
 
yea sry its correct rite?

Bugsy 06-11-2009 20:11

Re: [HELP] Last Problem! =]
 
It should, try it out and let me know. Quick question, why are you rounding a cvar?

malec321 06-11-2009 20:23

Re: [HELP] Last Problem! =]
 
rounding? lmao sry not so good with the scripting terms

malec321 06-11-2009 20:24

Re: [HELP] Last Problem! =]
 
i tryed it and i posted the new script and wat errors i got.


All times are GMT -4. The time now is 13:49.

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