SA-MP Forums Archive
How to make teams not attack each other?(No health lose). - 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: How to make teams not attack each other?(No health lose). (/showthread.php?tid=619952)



How to make teams not attack each other?(No health lose). - Gotham - 24.10.2016

Hi guys , The title kind of says it all!
Any Help?


Re: How to make teams not attack each other?(No health lose). - X337 - 24.10.2016

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

or use OnPlayerWeaponShot() callback and check player team inside it.
Example:
Код:
OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	if(hittype == BULLET_HIT_TYPE_PLAYER)
	{
		if(InSameTeam(playerid, hitid))
			return 0;
	}
	return 1;
}



Re: How to make teams not attack each other?(No health lose). - Gotham - 24.10.2016

Edit:Can you say how do I set the teams?(if the guy chose 1st team in spawn menu he would be in Team ID 1?)?I used SetPlayerTeam


Re: How to make teams not attack each other?(No health lose). - X337 - 24.10.2016

Код:
#define InSameTeam(%0,%1) (PlayerVariable[%0][TeamEnum] == PlayerVariable[%1][TeamEnum])
But i'd recommend you to use SetPlayerTeam instead of this.


Re: How to make teams not attack each other?(No health lose). - JaKe Elite - 24.10.2016

Since you are already using SetPlayerTeam as you stated, There will be no health loss issues when a team mate decided to shoot or kill their other team mates.


Re: How to make teams not attack each other?(No health lose). - Ronaldo1234 - 24.10.2016

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(GetTeam{issuerid} == CLASS_COPS || GetTeam{issuerid} == CLASS_CIA || GetTeam{issuerid} == CLASS_ARMY || GetTeam{issuerid} == CLASS_SWAT)
    {
    if(GetTeam{playerid} == CLASS_COPS || GetTeam{playerid} == CLASS_CIA || GetTeam{playerid} == CLASS_ARMY || GetTeam{playerid} == CLASS_SWAT)
    {
    	new Float:HP;
    	GetPlayerHealth(playerid, HP);
        if(GetPlayerWeapon(issuerid)) SetPlayerHealth(playerid, HP);
        // Armour System
        new Float:ARMOUR;
    	GetPlayerArmour(playerid, ARMOUR);
        if(GetPlayerWeapon(issuerid)) SetPlayerArmour(playerid, ARMOUR);
        // END
        SetPlayerHealth(playerid, 100.0);
        }
    }
return 1;
}



Re: How to make teams not attack each other?(No health lose). - ThatFag - 24.10.2016

Use SetPlayerTeam
it will not damage any player that are in the same team.

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