OnPlayerTakeDamage. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerTakeDamage. (
/showthread.php?tid=444009)
OnPlayerTakeDamage. -
Beckett - 14.06.2013
Well, what I want is if the player's armour is 100 it would take the armour first, for now it takes HP more than armour :3 , which means he dies before his armour is taken.
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new Float:HP;
GetPlayerHealth(playerid, HP);
if(weaponid == 24) SetPlayerHealth(playerid, HP-110);
if(weaponid == 22) SetPlayerHealth(playerid, HP-10);
if(weaponid == 32) SetPlayerHealth(playerid, HP-35);
if(weaponid == 28) SetPlayerHealth(playerid, HP-35);
if(weaponid == 23) SetPlayerHealth(playerid, HP-30);
if(weaponid == 31) SetPlayerHealth(playerid, HP-40);
if(weaponid == 30) SetPlayerHealth(playerid, HP-40);
if(weaponid == 29) SetPlayerHealth(playerid, HP-25);
if(weaponid == 34) SetPlayerHealth(playerid, HP-199);
if(weaponid == 33) SetPlayerHealth(playerid, HP-100);
if(weaponid == 25) SetPlayerHealth(playerid, HP-35);
if(weaponid == 27) SetPlayerHealth(playerid, HP-45);
return 1;
}
Thank you!
Re: OnPlayerTakeDamage. -
Pottus - 14.06.2013
1) Do it like this
pawn Код:
switch(weaponid)
{
case 24: { amount = 110; }
case 22: { amount = 10; }
......
}
2)
pawn Код:
new Float:HP;
new Float:Armour;
GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, Armour);
Armour -= amount;
HP -= Armour;
if(Armour > 0.0) SetPlayerArmour(playerid, Armour);
else
{
SetPlayerArmour(playerid, 0.0);
if(HP <= 0.0) SetPlayerHealth(playerid, 0.0);
else SetPlayerHealth(playerid, HP);
}
Re: OnPlayerTakeDamage. -
Beckett - 14.06.2013
I'll test it, thanks for replying.
Re: OnPlayerTakeDamage. -
Beckett - 14.06.2013
It's not working, when someone is getting shot his HP will be restored.
Re: OnPlayerTakeDamage. -
B-Matt - 14.06.2013
Here's mine code for health and armour adjusting.
pawn Код:
HealthAdjust(playerid, Float:Health, Float:Armour, Float:Damage)
{
if(armour <= 100.0)
Armour -= Damage;
if(armour <= 0.0)
{
Armour = 0.0;
Health -= Damage;
if(Health <= 0.0) Health = 0.0;
}
SetPlayerHealth(playerid, Health);
SetPlayerArmour(playerid, Armour);
return 1;
}
Example:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new Float:health, Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
if(issuerid != INVALID_PLAYER_ID)
{
switch(weaponid)
{
case 22: { //Colt
HealthAdjust(playerid, health, armour, amount+27.0);
}
}
}
return 1;
}