SA-MP Forums Archive
OnPlayerGiveDamage - 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: OnPlayerGiveDamage (/showthread.php?tid=513634)



OnPlayerGiveDamage - audriuxxx - 17.05.2014

Hi,

In this callback when i check damageid health i always get that health how much player have before hit? and then after some time, player health will be different?


Re: OnPlayerGiveDamage - audriuxxx - 17.05.2014

Code:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
new Float:Health;
GetPlayerHealth(damagedid, Heath);
}
Situation:

I have 100 HP. Somebody shoot my with deagle and i have to lose 46 HP. When Callback will be called, health will be 100 or 54 (that, because 100-46).


Re: OnPlayerGiveDamage - Abagail - 17.05.2014

Your doing it all wrong.

damageid is the ID of the player shot/that took the damage. While, amount is the amount of health they loose.

According to SA-MP Wiki,
playerid The ID of the player that gave damage.
damagedid The ID of the player that received damage.
amount The amount of health/armour damagedid has lost (combined).
weaponid The reason that caused the damage.
bodypart The body part that was hit. (NOTE: This parameter was added in 0.3z. Leave it out if using an older version!)

wiki.sa-mp.com/wiki/OnPlayerGiveDamage


Re: OnPlayerGiveDamage - audriuxxx - 17.05.2014

new string[128], victim[MAX_PLAYER_NAME], attacker[MAX_PLAYER_NAME];
new weaponname[24];
GetPlayerName(playerid, attacker, sizeof (attacker));
GetPlayerName(damagedid, victim, sizeof (victim));

GetWeaponName(weaponid, weaponname, sizeof (weaponname));
format(string, sizeof(string), "%s has made %.0f damage to %s, weapon: %s", attacker, amount, victim, weaponname);
SendClientMessageToAll(0xFFFFFFFF, string);


Re: OnPlayerGiveDamage - audriuxxx - 17.05.2014

UP THREAD.