VC:MP 0.3 > Snippet Showroom

[TUTORIAL] How to make a heal system (timed)

(1/1)

NE.Restricted:
In pawn, you cannot pass arguments using a timer.
Or can you!
To make a timed heal system requires some variables:

--- Code: ---new IsHealing[100];
new HealCount[100];
--- End code ---
Some definitions

--- Code: ---#define HEAL_HEALTH_AMOUNT 100 //the amount of heal you wanna give after healing
#define HEAL_TIME_SECONDS 10 //the time you want to take to heal in seconds
--- End code ---
And a timer, ofcourse

--- Code: ---public OnGameModeInit()
{
NewTimer("Healed", 1000, 1);
}
--- End code ---
And the timed function

--- Code: ---public Healed()
{
for(new i; i<=100; i++)
{
if(IsHealing[i]==1)
{
HealCount[i]++;
if(HealCount[i]== HEAL_TIME_SECONDS)
{
IsHealing[i] = 0;
SetPlayerHealth(i, HEAL_HEALTH_AMOUNT);
}
}
}
}
--- End code ---
and where you want to make the heal (example !heal)

--- Code: ---IsHealing[playerid] = 1;
HealCount[playerid] = 0;
--- End code ---

[NYB]fast:p:
Go hear http://nybsr.createaforum.com/fast-showroom/heal-in-5-sec/

NE.Restricted:

--- Quote from: [NYB]fast:p on August 21, 2014, 08:35:55 am ---Go hear http://nybsr.createaforum.com/fast-showroom/heal-in-5-sec/

--- End quote ---
Bugged!
This will healed ID 0 while the player wrote !heal wonder why he frozen and frozen and not unfreeze!

Navigation

[0] Message Index

Go to full version