Is there any way to cancel out OnPlayerTakeDamage? -
Gryphus One - 16.04.2012
I would like players to take no damage in certain and specific situations while keeping them vulnerable in others, so I have tried with putting
return 0; in such conditions, but I keep taking damage. Is there any way to achieve what I want?
Re: Is there any way to cancel out OnPlayerTakeDamage? -
@Riichard - 16.04.2012
Try putting, for each shot / disaster increase the life of the player!
xD
Respuesta: Is there any way to cancel out OnPlayerTakeDamage? -
Gryphus One - 16.04.2012
Well actually I have already made a custom RestoreDamage function with the parameters (playerid, Float:amount), calling this function in OnPlayerTakeDamage under some conditions. However, what if the player has armour too? OnPlayerTakeDamage doesn't tell you if the damage has been made to the armour or to the player's health. If I could somehow make the damage null it would be much better.
Re: Is there any way to cancel out OnPlayerTakeDamage? -
@Riichard - 16.04.2012
Tried
??
Re: Is there any way to cancel out OnPlayerTakeDamage? -
kizla - 16.04.2012
Well, you can use "SetPlayerTeam" and then players can kill each other if they are in the same team, unless they use knife...
Example:
pawn Код:
public OnPlayerConnect(playerid)
{
SetPlayerTeam(playerid, 7);
return 1;
}
Re: Is there any way to cancel out OnPlayerTakeDamage? -
Shetch - 16.04.2012
To see if a player is in a certain area use
https://sampwiki.blast.hk/wiki/Useful_Fu...IsPlayerInArea.
Also GetPlayerHealth, GetPlayerArmour.
Respuesta: Re: Is there any way to cancel out OnPlayerTakeDamage? -
Gryphus One - 16.04.2012
Quote:
Originally Posted by @Riichard
|
I have just tried it but doesn't work.
Re: Is there any way to cancel out OnPlayerTakeDamage? -
iggy1 - 16.04.2012
This would be pretty hard to do because even if you try to restore the players health/armour they might still die before you can. The best way would be to use teams like kizla said. But that means you must know in advance if you want to cancel a players damage
Respuesta: Is there any way to cancel out OnPlayerTakeDamage? -
Gryphus One - 16.04.2012
Ok, thanks to all of you for your replies, but I think I have just found the solution and the truth is that such solution is really easy: I found out that if you use GetPlayerHealth and GetPlayerArmour in OnPlayerTakeDamage, these functions return the health and armour values that you had BEFORE taking damage, so for example if you have full health and full armour, and suddenly you fall some meters and your health drops to 95, both functions will return 100, not 95 and 100. And I have also found out that if you use SetPlayerHealth and SetPlayerArmour in the OnPlayerTakeDamage callback, these two functions will have priority over the callback. Therefore, the solution to my problem seems to be the following:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new Float:health, Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
if( blah blah blah put your conditional here)
{
SetPlayerHealth(playerid, health);
SetPlayerArmour(playerid, armour);
// With this, the player will take no damage.
}
return 1;
}
Re: Is there any way to cancel out OnPlayerTakeDamage? -
iggy1 - 16.04.2012
Nice i thought it was called after taking damage.