How to apply animation when shot in leg
#1

I'd like something like LSRP, but idk how to add it when shot in the leg, this is my script
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new Float: health;
    new Float: armour;
    GetPlayerHealth(playerid, health);
    GetPlayerArmour(playerid, armour);
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(weaponid == 0)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 5); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 5); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 5);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 5); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 5);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 5); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 5); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 5); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 5); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 5);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 5); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 5);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 5); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 5); // Head.
                    }
                }
            }
        }
        else if(weaponid == 3)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 8); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 8); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 8);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 8); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 8);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 8); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 8); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 8); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 8); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 8);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 8); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 8);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 8); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 8); // Head.
                    }
                }
            }
        }
        else if(weaponid == 4)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 11); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 11); // Head.
                    }
                }
            }
        }
        else if(weaponid == 5)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 11); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 11); // Head.
                    }
                }
            }
        }
        else if(weaponid == 8)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 13); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 13); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 13);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 13); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 13);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 13); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 99); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 13); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 13); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 13);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 13); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 13);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 13); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 99); // Head.
                    }
                }
            }
        }
        else if(weaponid == 22)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 18); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 15); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 15);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 15); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 15);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 15); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 45); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 18); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 45); // Head.
                    }
                }
            }
        }
        else if(weaponid == 23)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 45); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 11); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 11); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 11);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 11); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 11);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 11); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 45); // Head.
                    }
                }
            }
        }
        else if(weaponid == 24)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 30); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 20); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 15);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 15); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 15);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 15); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 60); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 15); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 10); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 8);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 8); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 8);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 8); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 40); // Head.
                    }
                }
            }
        }
        else if(weaponid == 25)
        {
            switch(armour) // Creates a switch that switches through the armour float, and checks the value.
            {
                case 0: // If the value is 0, the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 40); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 20); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 15);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 15); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 15);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 15); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 100); // Head.
                    }
                }
                default: // Otherwise the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 20); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 10); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 7);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 7); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 7);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 7); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 50); // Head.
                    }
                }
            }
        }
        else if(weaponid == 29)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 15); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 10); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 10);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 10); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 10);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 10); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 50); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 10); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 10); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 5);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 5); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 5);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 5); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 25); // Head.
                    }
                }
            }
        }
        else if(weaponid == 30)
        {
            switch(armour) // Creates a switch that switches through the armour float, and checks the value.
            {
                case 0: // If the value is 0, the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 35); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 35); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 20);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 20); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 14);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 14); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 50); // Head.
                    }
                }
                default: // Otherwise the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 15); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 15); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 10);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 10); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 7);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 7); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 50); // Head.
                    }
                }
            }
        }
        else if(weaponid == 31)
        {
            switch(armour) // Creates a switch that switches through the armour float, and checks the value.
            {
                case 0: // If the value is 0, the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 20); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 20); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 10);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 10); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 7);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 7); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 100); // Head.
                    }
                }
                default: // Otherwise the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 10); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 10); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 5);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 4); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 4);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 4); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 50); // Head.
                    }
                }
            }
        }
        else if(weaponid == 32)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 15); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 15); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 15);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 15); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 15);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 15); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 50); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 10); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 10); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 10);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 10); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 10);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 10); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 25); // Head.
                    }
                }
            }
        }
        else if(weaponid == 33)
        {
            switch(armour)
            {
                case 0:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 40); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 25); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 15);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 15); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 15);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 15); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 100); // Head.
                    }
                }
                default:
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 25); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 15); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 5);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 5); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 5);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 5); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 70); // Head.
                    }
                }
            }
        }
        else if(weaponid == 34)
        {
            switch(armour) // Creates a switch that switches through the armour float, and checks the value.
            {
                case 0: // If the value is 0, the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerHealth(playerid, health - 60); // Torso.
                        case 4: SetPlayerHealth(playerid, health - 35); // Groin.
                        case 5: SetPlayerHealth(playerid, health - 20);  // Left Arm.
                        case 6: SetPlayerHealth(playerid, health - 20); // Right Arm.
                        case 7: SetPlayerHealth(playerid, health - 20);  // Left Leg.
                        case 8: SetPlayerHealth(playerid, health - 20); // Right Leg.
                        case 9: SetPlayerHealth(playerid, health - 100); // Head.
                    }
                }
                default: // Otherwise the codes underneath will activate.
                {
                    switch(bodypart)
                    {
                        case 3: SetPlayerArmour(playerid, armour - 25); // Torso.
                        case 4: SetPlayerArmour(playerid, armour - 15); // Groin.
                        case 5: SetPlayerArmour(playerid, armour - 5);  // Left Arm.
                        case 6: SetPlayerArmour(playerid, armour - 5); // Right Arm.
                        case 7: SetPlayerArmour(playerid, armour - 5);  // Left Leg.
                        case 8: SetPlayerArmour(playerid, armour - 5); // Right Leg.
                        case 9: SetPlayerArmour(playerid, armour - 70); // Head.
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#2

For all weapons?
Reply
#3

Only for firearms, if he get shot in the leg apply the limp anim.
Reply
#4

Well, add it in bodypart 7 and 8 for the weapons you want
Reply
#5

But how....
Reply
#6

If the player tries to jump or sprint and has been shot in the leg(use a variable for this, make sure you clear it when they're not supposed to limp anymore), apply the animation. You can detect this in OnPlayerKeyStateChange.

KEY_JUMP, KEY_SPRINT
Reply
#7

PHP код:
switch(bodypart)
                    {
                        
//blabla
                        
case 7
                        {
                            
SetPlayerHealth(playeridhealth 5);  // Left Leg.
                            
ApplyAnimation...
                        }
                        case 
8
                        {
                            
SetPlayerHealth(playeridhealth 5); // Right Leg.
                            
ApplyAnimation...
                        }
                        
//blabla
                    

Reply
#8

Thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)