Please Help Me Out!
#1

Hello everyone! I need a little bit of help. I am trying to make a check to get a players health, and if it is less than or equal to 5 I want them to perform an animation basically leavign them there performing that animation until they die, and be fine when they respawn.

Here is what I am using for this:
Код:
forward DeathCheck();   /// My Forward Of Course

public DeathCheck()   /// The Function Itself Above Main
{
  for(new i= 0; i < MAX_PLAYERS; i++)
  {
    new Float:health;
    GetPlayerHealth(i, Float:health);
    if(GetPlayerHealth(i, Float:health) <= 5);
    {
      ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.0,1,0,0,0,0);
    }
  }
  return 1;
}

SetTimer("DeathCheck", 1000, 1);   /// The Timer For The Function Under OnGameModeInIt
I am not sure what I forgot or why it will not work right. If it does work it is, when a player selects their skins and then continues after they spawn when it should not(I have also tried to add in a check to make sure they were spawned and no luck it still did the anim). It's kind of hard to explain I am sorry, but if you can help me with this I would appreciate it! Thanks in advance!
Reply
#2

Код:
   new Float:health;
   do
   {
     something
   }
   while(GetPlayerHealth(playerid, health) <5)
}
Reply
#3

Thank you so much I will try it and reply!
Reply
#4

Код:
#include <a_samp>

forward DeathCheck(playerid);
new CheckTimer[MAX_PLAYERS];

public DeathCheck(playerid)
{
	new Float:Health;
 	do
 	{
		ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.1,1,1,1,1,1);
	}
	while(GetPlayerHealth(playerid, Health) <= 5);
  return 1;
}

public OnPlayerConnect(playerid)
{
	CheckTimer[playerid] = SetTimerEx("DeathCheck", 1000, true, "i", playerid);
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	KillTimer(CheckTimer[playerid]);
	return 1;
}
Here I made this for you; test it..
Reply
#5

Quote:
Originally Posted by [WsR
RyDeR ]
Код:
#include <a_samp>

forward DeathCheck(playerid);
new CheckTimer[MAX_PLAYERS];

public DeathCheck(playerid)
{
	new Float:Health;
 	do
 	{
		ApplyAnimation(playerid, "SWEET", "Sweet_injuredloop", 4.1,1,1,1,1,1);
	}
	while(GetPlayerHealth(playerid, Health) <5);
  return 1;
}

public OnPlayerConnect(playerid)
{
	CheckTimer[playerid] = SetTimerEx("DeathCheck", 1000, true, "i", playerid);
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	KillTimer(CheckTimer[playerid]);
	return 1;
}
Here I made this for you; test it..
Thank you so much, but now it is doing it when the player spawns with full health, and even if I try to perform another animation it send them back to doing this one. I only want this animation done when a player has <= 5 HP and when they re-spawn the animation will be finished, while the timer keeps ticking. I am not asking for a handout either I just would like to know what I am doing wrong!
Reply
#6

notec, your code was already fine
ryder, your code would stop the server from working (infinity loop)

your only problem was that you have no clue how to use a function like GetPlayerHealth, check the wiki page => CLICK

but you should create the health variable before the loop because if it would be in, it would create it each time the loop starts again (that would be 500 (MAX_PLAYER) times)
and you should check if the player is online, apply animations on ghosts is quite useless and only waste time
Reply
#7

I figured it out!! Thank you to those who replied! What I did wrong was the health check thing and then after that I stuck it in OnPlayerUpdate and it works like a charm! Thanks again!
Reply
#8

Wait.. do you run a timer in OnPlayerUpdate?
That's just not neccessary.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)