Disabling weapon damage - 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: Disabling weapon damage (
/showthread.php?tid=565006)
Disabling weapon damage -
Albon - 24.02.2015
Is there a way to disable weapon damage? I tried returning false on OnPlayerGiveDamage or OnPlayerTakeDamage but none of them seem to work. I have also tried to re-set the player's HP to the current thus it will prevent damage from being applied, however sometimes when the player has like 10 HP and he gets shot with an M4 he'll die because the damage of it is usually more than 10 HP..
Re: Disabling weapon damage -
ball - 24.02.2015
Return 0 in OnPlayerWeaponShot - other damage like punching or fire can't be stopped, only re-setting the player's HP will work, but players with low HP will die.
Re: Disabling weapon damage -
Albon - 24.02.2015
When I return 0 in OnPlayerWeaponShot both calls back GiveDamage and TakeDamage won't be called thus I can't tell which body part they actually shot :X
Re: Disabling weapon damage -
De4dpOol - 24.02.2015
pawn Код:
//Under OnPlayerTakeDamage//
new Float:m_health;
GetPlayerHealth(playerid, m_health);
SetPlayerHealth(playerid, m_health + amount);
return 1;
This will give them the health they lost.
Re: Disabling weapon damage -
CalvinC - 24.02.2015
In OnPlayerTakeDamage, there's a float called amount, which is how much the player was damaged, therefore you can just set the player's health + amount.
pawn Код:
new Float:health, Float:armour; // Creates 2 floats, "health" and "armour"
GetPlayerHealth(playerid, health); // Stores the player's health value in the float "health"
GetPlayerArmour(playerid, armour); // Stores the player's armour value in the float "amour"
if(armour > 0) SetPlayerArmour(playerid, armour + amount); // Otherwise sets the players armour to his current armour, plus the damage that he took, removing the damage
else SetPlayerHealth(playerid, health + amount); // Otherwise sets the players health to his current health, plus the damage that he took, removing the damage
Although if he has very low health, he can still die from it before the script can set his health back.