28.08.2013, 16:32
If you have 24 percent of armour, and you shoot three times, it gets (for the first one) 24 percent of armour and the rest 12 of the health. However, if you have 2 percent of armour, it won't set the armour.
Oh and by the way, armour is stored already to armour, so doing:
is useless.
Switching through weaponid is faster that if statements. Anyways, to prevent what I told you above I made a fix. It should work.
Oh and by the way, armour is stored already to armour, so doing:
pawn Код:
if(GetPlayerArmour(playerid, armour) > 0)
Switching through weaponid is faster that if statements. Anyways, to prevent what I told you above I made a fix. It should work.
pawn Код:
public OnPlayerTakeDamage( playerid, issuerid, Float: amount, weaponid )
{
if( issuerid != INVALID_PLAYER_ID )
{
if( pData[ issuerid ][ AdminDuty ] ) return 1;
new
Float: health,
Float: armour,
Float: calc_rest
;
GetPlayerHealth( playerid, health );
GetPlayerArmour( playerid, armour );
switch( weaponid )
{
case 7:
{
if( armour > 12.0 ) SetPlayerArmour( playerid, armour - 12.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 12.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 12.0 );
}
}
case 8:
{
if( armour > 20.0 ) SetPlayerArmour( playerid, armour - 20.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 20.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 20.0 );
}
}
case 4:
{
if( armour > 20.0 ) SetPlayerArmour( playerid, armour - 20.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 20.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 20.0 );
}
}
case 3:
{
if( armour > 11.0 ) SetPlayerArmour( playerid, armour - 11.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 11.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 11.0 );
}
}
case 5:
{
if( armour > 9.0 ) SetPlayerArmour( playerid, armour - 9.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 9.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 9.0 );
}
}
case 23:
{
if( armour > 19.0 ) SetPlayerArmour( playerid, armour - 19.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 19.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 19.0 );
}
}
case 24:
{
if( armour > 65.0 ) SetPlayerArmour( playerid, armour - 65.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 65.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 65.0 );
}
}
case 22:
{
if( armour > 20.0 ) SetPlayerArmour( playerid, armour - 20.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 20.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 20.0 );
}
}
case 27:
{
if( armour > 32.0 ) SetPlayerArmour( playerid, armour - 32.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 32.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 32.0 );
}
}
case 28:
{
if( armour > 18.0 ) SetPlayerArmour( playerid, armour - 18.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 18.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 18.0 );
}
}
case 29:
{
if( armour > 22.0 ) SetPlayerArmour( playerid, armour - 22.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 22.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 22.0 );
}
}
case 30:
{
if( armour > 25.0 ) SetPlayerArmour( playerid, armour - 25.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 25.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 25.0 );
}
}
case 31:
{
if( armour > 25.0 ) SetPlayerArmour( playerid, armour - 25.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 25.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 25.0 );
}
}
case 32:
{
if( armour > 18.0 ) SetPlayerArmour( playerid, armour - 18.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 18.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 18.0 );
}
}
case 34:
{
if( armour > 300.0 ) SetPlayerArmour( playerid, armour - 300.0 );
else
{
if( armour > 0.0 )
{
calc_rest = 300.0 - armour;
SetPlayerArmour( playerid, 0.0 );
SetPlayerHealth( playerid, health - calc_rest );
}
else SetPlayerHealth( playerid, health - 300.0 );
}
}
}
}
return 1;
}