Prevent damage to teammates
#1

I have this in my OnPlayerTakeDamage callback:
pawn Code:
if(PlayerTeamID[issuerid] == PlayerTeamID[playerid])
{
    SendClientMessage(issuerid, -1, "Do not damage to your teammates.");
    return false;
}
The problem is that when a teammate damage me, I lose my health.
Even this message is shown to my teammate, "Do not damage to your teammates."
How do I fix it
Reply
#2

OnPlayerTakeDamage:
Return Values:
1 - Callback will not be called in other filterscripts.
0 - Allows this callback to be called in other filterscripts.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.


But..
If you use weapon-config include:
returning false in OnPlayerDamage will prevent damage from being inflicted.
Reply
#3

You could simply use SetPlayerTeam() instead.
https://sampwiki.blast.hk/wiki/SetPlayerTeam

Quote:

Players can not damage/kill players on the same team unless they use a knife to slit their throat. As of SA-MP 0.3x, players are also unable to damage vehicles driven by a player from the same team. This can be enabled with EnableVehicleFriendlyFire.

Reply
#4

Quote:
Originally Posted by algorhitmically
View Post
OnPlayerTakeDamage:
Return Values:
1 - Callback will not be called in other filterscripts.
0 - Allows this callback to be called in other filterscripts.
It is always called first in filterscripts so returning 1 there blocks other filterscripts from seeing it.


But..
If you use weapon-config include:
returning false in OnPlayerDamage will prevent damage from being inflicted.
Thanks to your reply but i use SetPlayerTeam.

Quote:
Originally Posted by Kwarde
View Post
You could simply use SetPlayerTeam() instead.
https://sampwiki.blast.hk/wiki/SetPlayerTeam
Yeah, is better to use SetPlayerTeam.
Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)