[HELP] Weapon Damages
#1

Alright, so, what I want to accomplish is custom damage values for each bodypart. Yet, I want it to detect if the player has armour or not. If the player has armor, don't take their health along with their armour, just take armor. if they don't have armor, just take health.
Here's my current code and it doesn't work and I get an error:
Код:
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)
            {
                if(armour <= 0)
				{
					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.
						}
					}
				}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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 - 45); // Head.
						}
					}
				else if(armor >=1)
				{
					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 == 23)
        {
            switch(armour)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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 == 22)
        {
            switch(armour)
            {
				if(armour <= 0)
				{
					case 0:
					{
						switch(bodypart)
						{
							case 3: SetPlayerHealth(playerid, health - 25); // 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 - 10);  // Left Leg.
							case 8: SetPlayerHealth(playerid, health - 10); // Right Leg.
							case 9: SetPlayerHealth(playerid, health - 50); // Head.
						}
					}
				else if(armor >=1)
				{
					default:
					{
						switch(bodypart)
						{
							case 3: SetPlayerArmour(playerid, armour - 13); // 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 == 24)
        {
            switch(armour)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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)
            {
				if(armour <= 0)
				{
					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.
						}
					}
				else if(armor >=1)
				{
					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.
						}
					}
				}
            }
        }
    }
Код:
C:\Users\Disloyal\Desktop\GTA Related\Prospect\gamemodes\roleplay.pwn(17153) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Disloyal\Desktop\GTA Related\Prospect\gamemodes\roleplay.pwn(17153 -- 17154) : error 028: invalid subscript (not an array or too many subscripts): "armour"
C:\Users\Disloyal\Desktop\GTA Related\Prospect\gamemodes\roleplay.pwn(17153 -- 17155) : error 001: expected token: "}", but found "case"
C:\Users\Disloyal\Desktop\GTA Related\Prospect\gamemodes\roleplay.pwn(17153 -- 17155) : fatal error 107: too many error messages on one line
Reply
#2

Can you explain to us (or yourself) what do you think this does?
Код:
switch(armour)
I'll help you in a way you can understand what is going on. Please just ignore me if what you want is someone to fix your code for you to copy/paste.
Reply
#3

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Can you explain to us (or yourself) what do you think this does?
Код:
switch(armour)
I'll help you in a way you can understand what is going on. Please just ignore me if what you want is someone to fix your code for you to copy/paste.
I understand what it does. It's SUPPOSED to do what I want to accomplish. Yet, it removes health and armor at the same time even with that.
Reply
#4

If you do, then can you explain me what is the meaning of this?

Код:
            switch(armour)
            {
                if(armour <= 0)
				{
					case 0:
Reply
#5

Quote:
Originally Posted by Troydere
Посмотреть сообщение
If you do, then can you explain me what is the meaning of this?

Код:
            switch(armour)
            {
                if(armour <= 0)
				{
					case 0:
It's contradicting itself, I know that. I don't know how to write it properly, that's why I came here for help.
ANYWAYS, what it does is this:
Код:
            switch(armour) //Checks if player has armor.
            {
                if(armour <= 0) //Checks if player's armor is 0 or less than that.
				{
					case 0: //When Armor is 0, do whatever
Yet, even without the
Код:
if(armour <= 0) //Checks if player's armor is 0 or less than that.
{
It still removes the player's health and armor at the same time. Not just armor.
Reply
#6

I made a quick code and I do not know if it works or not as I haven't tried it yet;

pawn Код:
stock RemovePlayerHealth(playerid, Float:damage)
{
    new Float:pHealth, Float:pArmour, Float:remArmour, Float:exArmour;
   
    GetPlayerHealth(playerid, pHealth);
    GetPlayerArmour(playerid, pArmour);
   
    if(pArmour > 0)
    {
        if(damage > pArmour)
        {
            exArmour = damage - pArmour;
            SetPlayerArmour(playerid, 0);
            SetPlayerHealth(playerid, pHealth-exArmour);
        }
        else if(pArmour > damage)
        {
            remArmour = pArmour - damage;
            SetPlayerArmour(playerid, remArmour)
        }
    }
}
It should go for RemovePlayerHealth(playerid, XXX); instead of SetPlayerHealth.
Reply
#7

Quote:
Originally Posted by oSAINTo
Посмотреть сообщение
It's contradicting itself, I know that. I don't know how to write it properly, that's why I came here for help.
ANYWAYS, what it does is this:
Код:
            switch(armour) //Checks if player has armor.
            {
                if(armour <= 0) //Checks if player's armor is 0 or less than that.
				{
					case 0: //When Armor is 0, do whatever
Yet, even without the
Код:
if(armour <= 0) //Checks if player's armor is 0 or less than that.
{
It still removes the player's health and armor at the same time. Not just armor.
Sorry if I looked mean, that was not my intention at all.

The code should be working if you remove these if checks, the errors happened because you skipped a bracket at the (weaponid == 34) condition. However, instead of filling the bracket, remove the unneeded conditions.

If the code just does not work and the user still gets their health taken when they should not, you may want to check in other callback like OnPlayerGiveDamage or OnPlayerWeaponShot.

EDIT:

Oopsey! I found a flaw, apparently if you put negative values in SetPlayerArmour it'll get to a positive value, then you will never get to have the player armour in 0.

The code provided by the guy above will help you to overcome this issue. Once again, if you're still having trouble, check for other callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)