22.03.2017, 19:54
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:
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