SA-MP Forums Archive
Need help with damage count - 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: Need help with damage count (/showthread.php?tid=305991)



Need help with damage count - aybo - 24.12.2011

Hi there. I need help with damage count.
We are creating an attack versus defend mode. After base finishes, we have a dialogue which shows who did how many kill and damage. Problem is, if you killed a guy which had 15hp(for example) with deagle it says you took 46 hp from the guy you killed. But it shouldn't be more damage than the guy has. If you hit a guy who has 40 damage with deagle, it should count it as 40 damage, not 46.
Hope you got it. Thanks


Re: Need help with damage count - Norck - 24.12.2011

Here you go:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
    new Float:damage = (amount > hp) ? hp : amount;  // this is the value you need
// ...
    return 1;
}
Hope I get you right.


Re: Need help with damage count - aybo - 24.12.2011

Quote:
Originally Posted by Norck
Посмотреть сообщение
Here you go:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:hp;
    GetPlayerHealth(playerid,hp);
    new Float:damage = (amount > hp) ? hp : amount;  // this is the value you need
// ...
    return 1;
}
Hope I get you right.
Thanks for giving time. I'll try it.