Hp script
#1

Hi, have a little bit of samp but find nothing. There is something script when you have examples below 50 hp so you fall to the ground? or if someone wants to help how to fix it
Reply
#2

Use a timer or use onplayerupdate ( i think it will work)
pawn Код:
new Float:phealth;
GetPlayerHealth(playerid,phealth);
if(phealth < 51)
{
    //apply the fall animation
    TogglePlayerControllable(playerid,0);
    SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
    return 1;
}
try that
Reply
#3

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Use a timer or use onplayerupdate ( i think it will work)
pawn Код:
new Float:phealth;
GetPlayerHealth(playerid,phealth);
if(phealth < 51)
{
    //apply the fall animation
    TogglePlayerControllable(playerid,0);
    SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
    return 1;
}
try that
one problem when i get under 51 hp is spam You have falled to the ground because you are injured how too fix that ?
Reply
#4

umm you added it in timer? if so try using it onplayerupdate. Or maybe if your using onplayerupdate and it doesnt work on timer, try doing the bottom with your timer.
pawn Код:
new HPTimer[MAX_PLAYERS];
^ thats on top,
pawn Код:
SetTimerEx("FallDown",100,true,"i",playerid);
^ thats on playerspawn
pawn Код:
forward FallDown(playerid);
public FallDown(playerid)
{
      new Float:phealth;
      GetPlayerHealth(playerid,phealth);
      if(phealth < 51)
      {
                 //apply the fall animation
                 TogglePlayerControllable(playerid,0);
                 SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
                 KillTimer(HPTimer[playerid]);
      }
      return 1;
}
^ thats anywhere in your script (just put it in the end)
Reply
#5

Thanks man <3 +rep
Reply
#6

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Thanks man <3 +rep
never knew that will work, no problem
Reply
#7

Lol that's so prone to bugs.

Just create a variable:

pawn Код:
new bool:IsPlayerDowned[MAX_PLAYERS];
Reset it in OnPlayerConnect (so there's no issues between new players joining with old in-use ID's)

pawn Код:
IsPlayerDowned[playerid] = false;
Finally, in your OnPlayerUpdate:

pawn Код:
public OnPlayerUpdate(playerid)
{
      new Float:phealth;
      GetPlayerHealth(playerid,phealth);
      if(phealth <= 50 && IsPlayerDowned[playerid] = false)
      {
          //apply the fall animation
          TogglePlayerControllable(playerid,0);
          SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
          IsPlayerDowned[playerid] = true;
      }
      return 1;
}
When you want him to stand up again, just clear animations, set his HP to above 50 and set IsPlayerDowned[playerid] to false.
Reply
#8

Quote:
Originally Posted by Rob_Maate
Посмотреть сообщение
Lol that's so prone to bugs.

Just create a variable:

pawn Код:
new bool:IsPlayerDowned[MAX_PLAYERS];
Reset it in OnPlayerConnect (so there's no issues between new players joining with old in-use ID's)

pawn Код:
IsPlayerDowned[playerid] = false;
Finally, in your OnPlayerUpdate:

pawn Код:
public OnPlayerUpdate(playerid)
{
      new Float:phealth;
      GetPlayerHealth(playerid,phealth);
      if(phealth <= 50 && IsPlayerDowned[playerid] = false)
      {
          //apply the fall animation
          TogglePlayerControllable(playerid,0);
          SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
          IsPlayerDowned[playerid] = true;
      }
      return 1;
}
When you want him to stand up again, just clear animations, set his HP to above 50 and set IsPlayerDowned[playerid] to false.
i get this then mabye help

Код:
C:\Users\Robin\Desktop\New rp\gamemodes\RMRP.pwn(85578) : error 001: expected token: ";", but found ")"
C:\Users\Robin\Desktop\New rp\gamemodes\RMRP.pwn(85578) : error 029: invalid expression, assumed zero
C:\Users\Robin\Desktop\New rp\gamemodes\RMRP.pwn(85578) : fatal error 107: too many error messages on one line
Код:
new Float:phealth;
	GetPlayerHealth(playerid,phealth);
line 85578	if(phealth <= 50 && IsPlayerDowned[playerid] = false)
	{
		//apply the fall animation
		TogglePlayerControllable(playerid,0);
		SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
		IsPlayerDowned[playerid] = true;
	}
	return 1;
Reply
#9

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
umm you added it in timer? if so try using it onplayerupdate. Or maybe if your using onplayerupdate and it doesnt work on timer, try doing the bottom with your timer.
pawn Код:
new HPTimer[MAX_PLAYERS];
^ thats on top,
pawn Код:
SetTimerEx("FallDown",100,true,"i",playerid);
^ thats on playerspawn
pawn Код:
forward FallDown(playerid);
public FallDown(playerid)
{
      new Float:phealth;
      GetPlayerHealth(playerid,phealth);
      if(phealth < 51)
      {
                 //apply the fall animation
                 TogglePlayerControllable(playerid,0);
                 SendClientMessage(playerid,-1,"You have falled to the ground because you are injured");
                 KillTimer(HPTimer[playerid]);
      }
      return 1;
}
^ thats anywhere in your script (just put it in the end)
i use the new code but still spmming You have falled to the ground because you are injured :P
Reply
#10

anyone know how ? :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)