autocrack when player have under 29 hp
#1

FIXED
Reply
#2

Please dont judge me guys, I maybe dont know what I am talking about but in my head this popped up.

pawn Код:
new Float:health;
    GetPlayerHealth(playerid,health);
    if(health >= 29)
    {
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid, 1);
    }
    else if(health <= 29)
    {
        TogglePlayerControllable(playerid, 0);
        LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    }
What if the >= 29 health was first? Maybe that would help? ;/
Reply
#3

Delete this post.
Reply
#4

Quote:
Originally Posted by DavidSparks
Посмотреть сообщение
Please dont judge me guys, I maybe dont know what I am talking about but in my head this popped up.

pawn Код:
new Float:health;
    GetPlayerHealth(playerid,health);
    if(health >= 29)
    {
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid, 1);
    }
    else if(health <= 29)
    {
        TogglePlayerControllable(playerid, 0);
        LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    }
What if the >= 29 health was first? Maybe that would help? ;/
no man this don't work
Reply
#5

Must be something else you have in your script, that bit of code should work fine.
Reply
#6

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Must be something else you have in your script, that bit of code should work fine.
the problem is in this code wich i posted,because i tested when i delete that code my man in gta walk normally withouth freeze effect but when i delete the code i dont have crack
Reply
#7

Oh yeah nvm im stupid.
What you're doing is, unfreezing and removing all animations/actions from the player every time the player updates. (around 30 ms)

Replace with this:
pawn Код:
new Float:health;
    GetPlayerHealth(playerid,health);
    if(health <= 29 && lowhealth[playerid] == 0) // Will now detect if "lowhealth" variable is set to 0 AND the health is lower than 30
    {
        lowhealth[playerid] = 1; // Will set the "lowhealth" variable to 1, so that it wont repeatedly set the player in Crack animation and freeze him
        TogglePlayerControllable(playerid, 0);
        LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    }
    else if(health > 29 && lowhealth[playerid] == 1) // Will now detect if "lowhealth" variable is set to 1 AND health is higher than 29, also removed the " = " since it would make him both freeze and unfreeze if player had 29 health
    {
        lowhealth[playerid] = 0; // Will set the "lowhealth" variable to 0, so that it wont repeatedly unfreeze the player and clear his animations
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid, 1);
    }
And put this at the top of your script underneath your includes:
pawn Код:
new lowhealth[MAX_PLAYERS];
Which will create the "lowhealth" variable.
Reply
#8

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Oh yeah nvm im stupid.
What you're doing is, unfreezing and removing all animations/actions from the player every time the player updates. (around 30 ms)

Replace with this:
pawn Код:
new Float:health;
    GetPlayerHealth(playerid,health);
    if(health <= 29 && lowhealth[playerid] == 0) // Will now detect if "lowhealth" variable is set to 0 AND the health is lower than 30
    {
        lowhealth[playerid] = 1; // Will set the "lowhealth" variable to 1, so that it wont repeatedly set the player in Crack animation and freeze him
        TogglePlayerControllable(playerid, 0);
        LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    }
    else if(health > 29 && lowhealth[playerid] == 1) // Will now detect if "lowhealth" variable is set to 1 AND health is higher than 29, also removed the " = " since it would make him both freeze and unfreeze if player had 29 health
    {
        lowhealth[playerid] = 0; // Will set the "lowhealth" variable to 0, so that it wont repeatedly unfreeze the player and clear his animations
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid, 1);
    }
And put this at the top of your script underneath your includes:
pawn Код:
new lowhealth[MAX_PLAYERS];
Which will create the "lowhealth" variable.
Now works,but the only problem in this is when player click right mouse he stand up
Reply
#9

Use ApplyAnimation instead of LoopingAnim.
Reply
#10

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Use ApplyAnimation instead of LoopingAnim.
Not work

I make this and it's work but if player have above 29 hp he can't walk.

Код:
new Float:health;
    GetPlayerHealth(playerid,health);
    if(health <= 29 && lowhealth[playerid] == 0) // Will now detect if "lowhealth" variable is set to 0 AND the health is lower than 30
    {
        lowhealth[playerid] = 0; // Will set the "lowhealth" variable to 1, so that it wont repeatedly set the player in Crack animation and freeze him
        TogglePlayerControllable(playerid, 0);
        LoopingAnim(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
    }
    else if(health > 29 && lowhealth[playerid] == 1) // Will now detect if "lowhealth" variable is set to 1 AND health is higher than 29, also removed the " = " since it would make him both freeze and unfreeze if player had 29 health
    {
        lowhealth[playerid] = 1; // Will set the "lowhealth" variable to 0, so that it wont repeatedly unfreeze the player and clear his animations
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid, 1);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)