Freeze The Health
#1

Hey all, i want ask something. Is that possible to freeze health to 1 so if someone get shoot and he will not dead but he well down with health 1, if that possible can someone show the code?

Thank's
Reply
#2

Do you mean you want health to decrease by 1% each time the player is shot?
Reply
#3

No, i want if people get shoot that will not dead so the health will not go to 0 but always freeze to 1...

Example: I shoot people and that peole have 100 health so i shoot until he death (this death mean is the health is 1 and can't be decrease again and so i play the animation at there too)...
Reply
#4

I think it isn't possible with simple PAWN, because of the updates are sent first, then the callbacks are called.
Reply
#5

This may help.
Sorry if its wrong.
pawn Код:
public OnPlayerUpdate(playerid)
{
   if(GetPlayerHealth(playerid)==1)
   {
   SetPlayerHealth(playerid,2.00);
   return 1;
}
Reply
#6

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
This may help.
Sorry if its wrong.
pawn Код:
public OnPlayerUpdate(playerid)
{
   if(GetPlayerHealth(playerid)==1)
   {
   SetPlayerHealth(playerid,2.00);
   return 1;
}
Hem maybe this can work, i will try this later and i want see people will death or not
Reply
#7

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
This may help.
Sorry if its wrong.
pawn Код:
public OnPlayerUpdate(playerid)
{
   if(GetPlayerHealth(playerid)==1)
   {
   SetPlayerHealth(playerid,2.00);
   return 1;
}
Well,YES,it is wrong,because GetPlayerHealth only STORES the health into a float variable DEFINED by YOU.So the correct code,would be:
pawn Код:
public OnPlayerUpdate(playerid)
{
   new Float:health;
   GetPlayerHealth(playerid,health);
   if(health==1)
   {
      SetPlayerHealth(playerid,2);
   }
   return 1;
}
YET,you are not completely wrong,why?He asked if player's health is smaller than 1,then his health should go back to 1,BUT,OnPlayerUpdate is like a "timer" of 1 second,and I am afraid that if his health goes below 1,BEFORE THE OnPlayerUpdate code executes and prepares to set his health to 1(EVEN if it acts in 1 second),he may be killed,and his health may be 1,but death also,the result is an annoying BUG.Bla bla,so well tought Lordz,you're not completly wrong,BUT,when you do wanna help AS a newbie,first check the function on SAMP-Wiki.
Reply
#8

pawn Код:
SetPlayerHealth(playerid,1);
That's it.
Reply
#9

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
    new Float:h;
    GetPlayerHealth(damagedid,h);
    SetPlayerHealth(damagedid,h+amount);
    //Was needed to make sure he do not die.
    SetPlayerHealth(damagedid,1);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)