Auto-crack system problem.
#1

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 ?
Reply
#2

do
SetTimerEx("HealthCheck", 1000, true, "i", playerid);

OnPlayerSpawn, then on death have it kill itself
Reply
#3

With KillTimer ?
Reply
#4

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.
Reply
#5

Going to test.
EDIT:
Character isn't getting animation, maybe something with ApplyAnimation ?
Reply
#6

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.
Reply
#7

Well, the animation is not applying to the character, anyone has any idea ?
Reply
#8

I did the auto-crack system again, but player isn't applying animation.
http://pastebin.com/m0WYSQW4
Reply
#9

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;
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)