Help with weapon damage system thanks -
JessThompson - 14.07.2014
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(issuerid != INVALID_PLAYER_ID)
{
switch(weaponid)
{
case 22:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-13); // Torso
case 4: SetPlayerHealth(playerid, HP-8); // Groin
case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
case 9: SetPlayerHealth(playerid, HP-26); // Head
}
}
case 23:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-15); // Torso
case 4: SetPlayerHealth(playerid, HP-12); // Groin
case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
case 9: SetPlayerHealth(playerid, HP-25); // Head
}
}
case 24:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-23); // Torso
case 4: SetPlayerHealth(playerid, HP-20); // Groin
case 5: SetPlayerHealth(playerid, HP-15); // Left ARM
case 6: SetPlayerHealth(playerid, HP-15); // Right ARM
case 7: SetPlayerHealth(playerid, HP-15); // Left Leg
case 8: SetPlayerHealth(playerid, HP-15); // Right Leg
case 9: SetPlayerHealth(playerid, HP-67); // Head
}
}
case 25:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-30); // Torso
case 4: SetPlayerHealth(playerid, HP-27); // Groin
case 5: SetPlayerHealth(playerid, HP-23); // Left ARM
case 6: SetPlayerHealth(playerid, HP-23); // Right ARM
case 7: SetPlayerHealth(playerid, HP-22); // Left Leg
case 8: SetPlayerHealth(playerid, HP-22); // Right Leg
case 9: SetPlayerHealth(playerid, HP-70); // Head
}
}
case 27:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-20); // Torso
case 4: SetPlayerHealth(playerid, HP-14); // Groin
case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
case 6: SetPlayerHealth(playerid, HP-10); // Right ARM
case 7: SetPlayerHealth(playerid, HP-9); // Left Leg
case 8: SetPlayerHealth(playerid, HP-9); // Right Leg
case 9: SetPlayerHealth(playerid, HP-70); // Head
}
}
case 28:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-10); // Torso
case 4: SetPlayerHealth(playerid, HP-8); // Groin
case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
case 9: SetPlayerHealth(playerid, HP-20); // Head
}
}
case 29:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-10); // Torso
case 4: SetPlayerHealth(playerid, HP-8); // Groin
case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
case 9: SetPlayerHealth(playerid, HP-20); // Head
}
}
case 30:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-21); // Torso
case 4: SetPlayerHealth(playerid, HP-14); // Groin
case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
case 9: SetPlayerHealth(playerid, HP-40); // Head
}
}
case 31:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-21); // Torso
case 4: SetPlayerHealth(playerid, HP-14); // Groin
case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
case 9: SetPlayerHealth(playerid, HP-40); // Head
}
}
case 32:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-10); // Torso
case 4: SetPlayerHealth(playerid, HP-8); // Groin
case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
case 9: SetPlayerHealth(playerid, HP-20); // Head
}
}
case 33:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-26); // Torso
case 4: SetPlayerHealth(playerid, HP-15); // Groin
case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
case 6: SetPlayerHealth(playerid, HP-14); // Right ARM
case 7: SetPlayerHealth(playerid, HP-10); // Left Leg
case 8: SetPlayerHealth(playerid, HP-14); // Right Leg
case 9: SetPlayerHealth(playerid, HP-40); // Head
}
}
case 34:
{
switch(bodypart)
{
case 3: SetPlayerHealth(playerid, HP-33); // Torso
case 4: SetPlayerHealth(playerid, HP-28); // Groin
case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
case 9: SetPlayerHealth(playerid, HP-100); // Head
}
}
}
}
return 1;
}
How could i make this so it checks if you have armour and the takes it off armour but if you don't have armour it takes it from health. +rep
Re: Help with weapon damage system thanks -
JessThompson - 14.07.2014
Anyone please?
Re: Help with weapon damage system thanks -
Don_Cage - 14.07.2014
pawn Code:
new armour;//defines the armour var..
GetPlayerArmour(playerid, armour);//Get the players armour
if(armour >= x)//Check if the armour is above a certain ammount (change the x.)
SetPlayerArmour(playerid, armour-ammount);//If the armour is higher than the ammount you checked, decrease it with the ammount you like..
//If the armour check is not higher, take the ammount form the health
Re: Help with weapon damage system thanks -
JessThompson - 14.07.2014
So would this work
pawn Code:
case 3: if(armour >= 0)
SetPlayerArmour(playerid, armour-10);
else SetPlayerHealth(playerid, HP-33); // Torso
case 4: SetPlayerHealth(playerid, HP-28); // Groin
case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
case 9: SetPlayerHealth(playerid, HP-100); // Head
Re: Help with weapon damage system thanks -
azzerking - 14.07.2014
The best way to do that is to check if the player armour is more then the you want to take off.
For example:
Your armour is: 30
Your health is 100
Your damage: 40
You first check to see if you have more armour then damage, if you have less then you get the player armour and take it away from the damage and then apply the remaining damage to health.
pawn Code:
new float:hp, float:armor;
GetPlayerHealth(playerid, hp);
GetPlayerArmor(playerid, armour);
if(armour > amount)
{
armour - amount;
SetPlayerArmor(playerid, armour);
}
else if(armour >= 0 && armour < amount)
{
amount - armour;
SetPlayerHealth(playerid, HP - amount);
}
This is untested but should work, unless I have missed something. If anyone finds anything wrong. Fell free to correct it.
Re: Help with weapon damage system thanks -
JessThompson - 15.07.2014
could you please link that up to the case because i need it to be linked up to the bodyparts thanks
Re: Help with weapon damage system thanks -
JessThompson - 15.07.2014
Well could you help me link it up to the damage system please +rep
Re: Help with weapon damage system thanks -
Pottus - 15.07.2014
You should just throw away all the code you have right now because it's all junk and is not how this kind of system should work. You need to use OnPlayerGiveDamage() the new lag compensation system isn't very reliable so it requires a helper system of course in doing this you can do a lot of other things such as specific damage amounts and completely server sided damage. In my opinion OnPlayerTakeDamage() is obsolete with lag comp enabled as there is significant missed shots when clearly the skin has been shot. We identified this issue very early on and you will see here on this server dedi.slice-vps.nl:8888 "Anti-lag enabled" in the bottom right corner.