Help with Health regen
#1

this is the code i am using and it works fine but it allways sets the players health to 0 when the player spawns then starts to regen the health

Код:
public HealthRegen(playerid)
{
  new Float:health;
	GetPlayerHealth(playerid,health);
  if (health < 100)
  {
    SetPlayerHealth(playerid, health +1);
//    	SendClientMessage(playerid, COLOR_RED, "DEBUG :- HEALTH REGEN !");
  }
}
i dont want it to set it to 0 as i have health and armour saving

could someone please take a look and give me a clue on where i have gone wrong or even point me in the right direction i have searched and only found the GTO one which is what i based this on.
Reply
#2

Quote:
Originally Posted by mister_ic3
this is the code i am using and it works fine but it allways sets the players health to 0 when the player spawns then starts to regen the health

Код:
public HealthRegen(playerid)
{
  new Float:health;
	GetPlayerHealth(playerid,health);
  if (health < 100)
  {
    SetPlayerHealth(playerid, health +1);
//   	SendClientMessage(playerid, COLOR_RED, "DEBUG :- HEALTH REGEN !");
  }
}
i dont want it to set it to 0 as i have health and armour saving

could someone please take a look and give me a clue on where i have gone wrong or even point me in the right direction i have searched and only found the GTO one which is what i based this on.
Try...
Код:
OnPlayerSpawn(playerid)
{
    SetPlayerHealth(playerid,100)
}
maybe that?
Reply
#3

you can make a Timer


e.g: every minute (60*1000 = 60 sec)
Код:
SetTimer("health_regen",60*1000,true);
Код:
public health_regen(playerid)
{
	new Float:health;
	GetPlayerHealth(playerid,health);
 	if (health < 100) // 
 	{
  	SetPlayerHealth(playerid,health+1);
   	}
}
and don't forget to put
Код:
forward health_regen(playerid)
at the top of your script


-Vince
Reply
#4

I'm sure that you can't use floats any more in SetPlayerHealth, use floatround() to round it and use an integer, I saw it on the wiki a while ago but it seems someone has edited that.

Here's the method I use:
Код:
new Float: PlHealth;
GetPlayerHealth(playerid, PlHealth);
new MathsFlaw = floatround(PlHealth, floatround_ceil);
SetPlayerHealth(playerid, MathsFlaw+1);
Reply
#5

That's only for NPCs. a_player's SetPlayerHealth still uses floats.

pawn Код:
public HealthRegen(playerid)
{
  if(GetPlayerState(playerid)=PLAYER_STATE_WASTED)return;
  new Float:health;
  GetPlayerHealth(playerid,health);
  if (health < 100)SetPlayerHealth(playerid, health +1);
}
Try something like that.
Reply
#6

Quote:
Originally Posted by Joe Staff
That's only for NPCs. a_player's SetPlayerHealth still uses floats.
Ah, right.
Reply
#7

Quote:
Originally Posted by Joe Staff
pawn Код:
public HealthRegen(playerid)
{
  if(GetPlayerState(playerid)=PLAYER_STATE_WASTED)return;
  new Float:health;
  GetPlayerHealth(playerid,health);
  if (health < 100)SetPlayerHealth(playerid, health +1);
}
one equal sign "=" is missing
Reply
#8

Thank you for all the replys i will go and try them now


EDIT :- sorry no luck it's still setting the health to 0 when i log in nevermind i will try to sort it out thanks again
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)