SA-MP Forums Archive
Healing over time effect[HELP] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Healing over time effect[HELP] (/showthread.php?tid=459515)



Healing over time effect[HELP] - eemalekorraks - 23.08.2013

Hello everybody, I know this might a bit too much to ask for but i'm looking to create a heal over time effect.

So upon typing /pills 5 the player would get a healing effect that healers the player for 3 hp every 1 second and for a total of 30 seconds. And then upon taking /pills 10 the (TIME) would double, not the effect, only the time so It would last for a minute.

Upon spawning a player should have 500 pills. And this resets after death.

I will surely give a helper REP UP! If you cannot create the script, maybe you can provide some guidelines.

Any help is apprecciated, regards Eemale!


Re: Healing over time effect[HELP] - RajatPawar - 23.08.2013

1) Create a public function to increase the player health by 1/3/w/e you want
2) Set a timer in the command
eg

pawn Код:
#define INVALID_TIMER -24
healer_timer[ MAX_PLAYERS ] = INVALID_TIMER;
forward public HealSlowly( playerid );


CMD:heal_me_over_time(playerid)
{
    healer_timer[ playerid ] = SetTimerEx("HealSlowly", 1000, 1, "d", playerid);
    return 1;
}

public HealSlowly( playerid )
{
      new Float: health_;
      GetPlayerHealth( playerid, health_ );
      if( health_ > 100) { KillTimer( healer_timer[ playerid ] ); healer_timer[ playerid ] = INVALID_TIMER; }
      Else SetPlayerHealth( playerid, health_ + 1 );
      return 1;
}

public OnPlayerDisconnect( playerid ..)
{
   healer_timer[ playerid ] = INVALID_TIMER;
   return 1;
}



Re: Healing over time effect[HELP] - eemalekorraks - 23.08.2013

Under the public
Код:
public HealSlowly( playerid )
{
      new health_;
      GetPlayerHealth( playerid, health_ );
      if( health_ > 100) { KillTimer( healer_timer[ playerid ] ); healer_timer[ playerid ] = INVALID_TIMER; }
      Else SetPlayerHealth( playerid, health_ + 1 );
      return 1;
}
There should be new Float:health_; btw

Anyways this seems working but the problem is that this wont last 30 seconds, it lasts untill my hp gets up to 100.
Thanks a bunch, Repped but could you help me out with thisone?


Re: Healing over time effect[HELP] - eemalekorraks - 23.08.2013

Also is there a way to do this.
Код:
ApplyAnimation(playerid,"SMOKING","M_smk_in",4.2,0,0,0,0,0,1);
So that upon pressing ENTER, it kills the animation halfway through.

Thanks in advance.


Re: Healing over time effect[HELP] - eemalekorraks - 24.08.2013

bump


Re: Healing over time effect[HELP] - xXSPRITEXx - 24.08.2013

Use a SetTimerEx that will heal you every * seconds you want and every * amount of health. Also while it is healing you. Make it apply the animation to the player "SMOKING". Hope this helps.