Prevent damage to teammates - 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: Prevent damage to teammates (
/showthread.php?tid=677034)
Prevent damage to teammates -
xRadical3 - 27.06.2020
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
Re: Prevent damage to teammates -
algorhitmically - 27.06.2020
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.
Re: Prevent damage to teammates -
Kwarde - 28.06.2020
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.
|
Re: Prevent damage to teammates -
xRadical3 - 28.06.2020
Quote:
Originally Posted by algorhitmically
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
|
Yeah, is better to use SetPlayerTeam.
Thanks