Hp drain ?? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Hp drain ?? (
/showthread.php?tid=184016)
Hp drain ?? -
Abraham2nd - 17.10.2010
ok can anyone tell me how to script this i has no idea! PLs
okay so when the peson gets hungry the hp slowly drains out maybe after every 5 hours (game time) the hp starts to drain? please help
im using ravens roleplay
Re: Hp drain ?? -
Nero_3D - 17.10.2010
I dont know how you make the person hungry but I suspect you use a timer
Just use that timer for decreasing, too
pawn Код:
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health - 1.0);
Re: Hp drain ?? -
Abraham2nd - 17.10.2010
i dont understand so i add this 2 times?
please make an example
Re: Hp drain ?? -
Kitten - 17.10.2010
this should work
pawn Код:
forward EatTimer(playerid);
public OnGameModeInit()
{
SetTimer("EatTimer",timeyouwant in miliseconds,true);
return 1;
}
public EatTimer(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health - 1.0); // you can change 1.0 to like 5.0 to lose more hp
return 1;
}
Re: Hp drain ?? -
Cameltoe - 17.10.2010
make something like this:
pawn Код:
#define HUNGER_BEFORE_DRAIN 5
#define DRAIN_HEALTH_AMOUNT 3
#define DRAIN_HEALTH_TIME 10000
new
Hunger[MAX_PLAYERS],
IsDraining[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Hunger[playerid] = HUNGER_BEFORE_DRAIN;
DrainTimer[playerid] = SetTimerEx("DrainHealth", DRAIN_HEALTH_TIME, "i", playerid); // Needs an timer id so you could kill it on player DC
}
public DrainHealth(playerid)
{
if(Hunger[playerid] == 0)
{
SetPlayerHealth(playerid, GetHealth(playerid) - DRAIN_HEALTH_AMOUNT);
}
else
{
Hunger[playerid]--;
}
}
stock GetHealth(playerid)
{
new Float: pHealth;
GetPlayerHealth(playerid, pHealth);
return pHealth;
}
should work, scripted in a hurry though..