SA-MP Forums Archive
Freeze The Health - 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: Freeze The Health (/showthread.php?tid=372085)



Freeze The Health - McCurdy - 25.08.2012

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


Re: Freeze The Health - Luke_James - 25.08.2012

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


Re: Freeze The Health - McCurdy - 25.08.2012

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)...


Respuesta: Freeze The Health - [DOG]irinel1996 - 25.08.2012

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


Re: Freeze The Health - Lordzy - 25.08.2012

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



Re: Freeze The Health - McCurdy - 25.08.2012

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


Re: Freeze The Health - Cjgogo - 25.08.2012

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.


Re: Freeze The Health - _Khaled_ - 25.08.2012

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


Re: Freeze The Health - [MM]RoXoR[FS] - 25.08.2012

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;
}