How to make teams not attack each other?(No health lose).
#1

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

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;
}
Reply
#3

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
Reply
#4

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

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.
Reply
#6

Код:
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;
}
Reply
#7

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)