SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/06/2020, 11:45 PM   #1
xRadical3
Gangsta
 
Join Date: May 2017
Location: Iran
Posts: 660
Reputation: 61
Unhappy Prevent damage to teammates

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
xRadical3 is offline   Reply With Quote
Old 27/06/2020, 11:58 PM   #2
algorhitmically
Little Clucker
 
Join Date: Feb 2020
Posts: 35
Reputation: 22
Default Re: Prevent damage to teammates

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.
algorhitmically is offline   Reply With Quote
Old 28/06/2020, 12:03 AM   #3
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,749
Reputation: 1686
Default Re: Prevent damage to teammates

You could simply use SetPlayerTeam() instead.
https://wiki.sa-mp.com/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.
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 28/06/2020, 09:36 AM   #4
xRadical3
Gangsta
 
Join Date: May 2017
Location: Iran
Posts: 660
Reputation: 61
Default Re: Prevent damage to teammates

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://wiki.sa-mp.com/wiki/SetPlayerTeam
Yeah, is better to use SetPlayerTeam.
Thanks
xRadical3 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Damage Nuginity Scripting Help 9 09/04/2020 01:06 PM
Prevent AFK Player Damage PoniStar Scripting Help 11 13/09/2018 06:26 AM
Does this prevent damage of any type? SeanDenZYR Scripting Help 1 25/05/2018 11:08 AM
[Tutorial] How to prevent damage Manyula Tutorials 8 04/05/2016 04:19 PM
only teammates visible on radar BlackWolf120 Help Archive 12 02/05/2011 08:07 PM


All times are GMT. The time now is 05:32 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.