30.04.2013, 16:35
DamagePlayer
Parameters: playerid, Float:damage
Function: Damages the player reducing the armour/health. If there's armour for player, it reduces it. If the damage is specified more than the armour, it reduces the health too.
Parameters: playerid, Float:damage
Function: Damages the player reducing the armour/health. If there's armour for player, it reduces it. If the damage is specified more than the armour, it reduces the health too.
pawn Код:
stock DamagePlayer(playerid, Float:damage)
{
new Float:temp_hp, Float:temp_arm;
GetPlayerHealth(playerid, temp_hp);
GetPlayerArmour(playerid, temp_arm);
if(temp_arm <= 0)
{
SetPlayerHealth(playerid, temp_hp - damage);
}
else if(temp_arm >= 1.00)
{
new Float:minus_result = temp_arm - damage;
// printf("%f", minus_result); //For debug.
if(minus_result <= 0.00)
{
SetPlayerArmour(playerid, 0.00);
SetPlayerHealth(playerid, minus_result + temp_hp);
}
else if(minus_result >= 1.00)
{
SetPlayerArmour(playerid, minus_result);
}
}
return 1;
}
pawn Код:
//Example:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
DamagePlayer(killerid, 20.00); //Reduces 20% of armour/hp.
}
return 1;
}