Auto-crack system problem. -
Darnell - 12.08.2011
I've created a timer that checks their health every second...
pawn Код:
forward HealthCheck(playerid);
public OnGameModeInit()
{
SetTimer("HealthCheck", 1000, true); // Set a timer of 1000 miliseconds (1 second)
return 1;
}
public HealthCheck(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 30.0)
{
ApplyAnimation(playerid,"PED","crckdeth2",2.1,1,1,1,1,1,1);
}
return 1;
}
I think I did something wrong with the ApplyAnimation function ?
Re: Auto-crack system problem. -
PrawkC - 12.08.2011
do
SetTimerEx("HealthCheck", 1000, true, "i", playerid);
OnPlayerSpawn, then on death have it kill itself
Re: Auto-crack system problem. -
Darnell - 12.08.2011
With KillTimer ?
Re: Auto-crack system problem. -
PrawkC - 12.08.2011
Quote:
Originally Posted by Darnell
With KillTimer ?
|
Yeah, so you'd have to assign the timer to a variable, so you can kill it.
Alternatively you may just be able to start the time onplayerconnect, but I'm just not sure what a players health is when not spawned, so it might cause problems, but you could try that first.
Re: Auto-crack system problem. -
Darnell - 12.08.2011
Going to test.
EDIT:
Character isn't getting animation, maybe something with ApplyAnimation ?
Re: Auto-crack system problem. -
Tee - 12.08.2011
Quote:
Originally Posted by PrawkC
Yeah, so you'd have to assign the timer to a variable, so you can kill it.
Alternatively you may just be able to start the time onplayerconnect, but I'm just not sure what a players health is when not spawned, so it might cause problems, but you could try that first.
|
Health is 0.0 when they connect and he can use OnGameModeInit to set the timer and in the timer have a loop through all players, but it's best to set it on spawn so you don't call the function when it's not needed.
Re: Auto-crack system problem. -
Darnell - 12.08.2011
Well, the animation is not applying to the character, anyone has any idea ?
Re: Auto-crack system problem. -
Darnell - 12.08.2011
I did the auto-crack system again, but player isn't applying animation.
http://pastebin.com/m0WYSQW4
Re: Auto-crack system problem. -
Tee - 12.08.2011
Wait i'll fix this post :S
EDIT: Ok try this:
pawn Код:
forward JustACheck(playerid);
public OnPlayerSpawn(playerid)
{
SetTimerEx("JustACheck", 1000, true, "i", playerid);
return 1;
}
public JustACheck(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if(health < 30.0)
{
ApplyAnimation(playerid,"PED","crckdeth2",2.1,1,1,1,1,1,1);
}
return 1;
}
Re: Auto-crack system problem. -
Darnell - 12.08.2011
Quote:
Originally Posted by Tee
Wait i'll fix this post :S
EDIT: Ok try this:
pawn Код:
forward JustACheck(playerid);
public OnPlayerSpawn(playerid) { SetTimerEx("JustACheck", 1000, true, "i", playerid); return 1; }
public JustACheck(playerid) { new Float:health; GetPlayerHealth(playerid,health); if(health < 30.0) { ApplyAnimation(playerid,"PED","crckdeth2",2.1,1,1,1,1,1,1); } return 1; }
|
You forgot to edit PED --> CRACK...
Though, when my player gets healed, I want him to be controlable again.
pawn Код:
public HealthCheck(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health > 30.0)
TogglePlayerControllable(playerid, 1);
return 1;
}
But it's resetting his animations always...