SA-MP Forums Archive
Undamage-able - 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: Undamage-able (/showthread.php?tid=573996)



Undamage-able - aCloudy - 12.05.2015

Hello, I have created two classes, Civilians and Cops.
pTeam[playerid] is for the teams, And the cops team is "teCop".

Can someone help me in making them cannot damage each other? I mean If Cop1 shoots Cop2, Cop2 won't be damaged, How ?


Re: Undamage-able - JaydenJason - 12.05.2015

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
	if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid)) // Little check to see if both players are on the same team
	{  
		new Float:hp; 
		GetPlayerHealth(playerid, hp); 
		SetPlayerHealth(playerid, hp-10.0);
		SendClientMessage(playerid, 0xFF6347AA, "You've shot your own teammate and therefore you have lost health!");
        }
}



Re: Undamage-able - aCloudy - 12.05.2015

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
	if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid)) // Little check to see if both players are on the same team
	{  
		new Float:hp; 
		GetPlayerHealth(playerid, hp); 
		SetPlayerHealth(playerid, hp-10.0);
		SendClientMessage(playerid, 0xFF6347AA, "You've shot your own teammate and therefore you have lost health!");
        }
}
Should I add return 0; under SendClientMessage function ?


Re: Undamage-able - JaydenJason - 12.05.2015

Quote:
Originally Posted by aCloudy
Посмотреть сообщение
Should I add return 0; under SendClientMessage function ?
I think so, try it and if it doesn't work post here again.


Re: Undamage-able - shadowdog - 12.05.2015

This is what you're looking for:

https://sampwiki.blast.hk/wiki/SetPlayerTeam

Set all cops on the same team so they can't damage each other.