SA-MP Forums Archive
How avoid ability from team attack - 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 avoid ability from team attack (/showthread.php?tid=628743)



How avoid ability from team attack - henkas - 14.02.2017

Hi!
how should i do that this ability doesn't drop on the ground team mates because now i can attack team and enemies so when i press alt everyone goes on the ground its rly annoying because if i make same think with freeze ability at same time i freeze enemies and team mates, so its rly fucked up. How should i avoid this. Here is code
Код:
	if(PRESSED(KEY_WALK))
	{
	    if(teams[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == SCREAMERZOMBIE)
			{
			    if(gettime() - 15 < Abilitys[playerid][ScreamerZombieAb]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
			    {
					foreach(new i : Player)
					{
          				switch(GetPlayerSkin(i))
     					{
     					    case NON_IMMUNE,285,181,249:
							{
	                            if(GetDistanceBetweenPlayers(playerid,i) < 5.0)
	                            {
							    	GetClosestPlayer(i);
	                                ApplyAnimation(i, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
	                                GameTextForPlayer(i,"~n~~n~~n~~n~~g~Screamer Attacked",3500,5);
	                                SetTimerEx("ScreamerClearAnim",1500,0,"i",i);
									GivePlayerXP(playerid,2);
									Abilitys[playerid][ScreamerZombieAb] = gettime();
								}
							}
						}
					}
				}
			}
		}
	}
Variable of teams

Код:
if(teams[playerid] == TEAM_ZOMBIE)
Код:
if(teams[playerid] == TEAM_HUMAN)



Re: How avoid ability from team attack - Rdx - 14.02.2017

foreach(new i : Player)
{
if(teams[playerid] == teams[i] ) continue;
// rest of your code


Re: How avoid ability from team attack - henkas - 14.02.2017

Like this?
Код:
	foreach(new i : Player)
    {
    if(teams[playerid] == teams[i] ) continue;
    
	if(PRESSED(KEY_WALK))
	{
	    if(teams[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == SCREAMERZOMBIE)
			{
			    if(gettime() - 15 < Abilitys[playerid][ScreamerZombieAb]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
			    {
          				switch(GetPlayerSkin(i))
     					{
     					    case NON_IMMUNE,285,181,249:
							{
	                            if(GetDistanceBetweenPlayers(playerid,i) < 5.0)
	                            {
							    	GetClosestPlayer(i);
	                                ApplyAnimation(i, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
	                                GameTextForPlayer(i,"~n~~n~~n~~n~~g~Screamer Attacked",3500,5);
	                                SetTimerEx("ScreamerClearAnim",1500,0,"i",i);
									GivePlayerXP(playerid,2);
									Abilitys[playerid][ScreamerZombieAb] = gettime();
								}
							}
						}
					}
				}
			}
		}
	}



Re: How avoid ability from team attack - Rdx - 14.02.2017

Nope, leave foreach on previous position.

Like that:

Код:
if(PRESSED(KEY_WALK))
	{
	    if(teams[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == SCREAMERZOMBIE)
			{
			    if(gettime() - 15 < Abilitys[playerid][ScreamerZombieAb]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
			    {
					foreach(new i : Player)
					{
                                        if(teams[playerid] == teams[i] ) continue;
          				switch(GetPlayerSkin(i))
     					{
     					    case NON_IMMUNE,285,181,249:
							{
	                            if(GetDistanceBetweenPlayers(playerid,i) < 5.0)
	                            {
							    	GetClosestPlayer(i);
	                                ApplyAnimation(i, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
	                                GameTextForPlayer(i,"~n~~n~~n~~n~~g~Screamer Attacked",3500,5);
	                                SetTimerEx("ScreamerClearAnim",1500,0,"i",i);
									GivePlayerXP(playerid,2);
									Abilitys[playerid][ScreamerZombieAb] = gettime();
								}
							}
						}
					}
				}
			}
		}
	}



Re: How avoid ability from team attack - henkas - 14.02.2017

Like this?
Код:
if(PRESSED(KEY_WALK))
	{
	    if(teams[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == SCREAMERZOMBIE)
			{
			    if(gettime() - 15 < Abilitys[playerid][ScreamerZombieAb]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
			    {
					foreach(new i : Player)
					{
                        if(teams[playerid] == teams[i] ) continue;
                        {
          				switch(GetPlayerSkin(i))
     					{
     					    case NON_IMMUNE,285,181,249:
							{
	                            if(GetDistanceBetweenPlayers(playerid,i) < 5.0)
	                            {
							    	GetClosestPlayer(i);
	                                ApplyAnimation(i, "PED", "BIKE_fall_off", 4.1, 0, 1, 1, 1, 0, 1);
	                                GameTextForPlayer(i,"~n~~n~~n~~n~~g~Screamer Attacked",3500,5);
	                                SetTimerEx("ScreamerClearAnim",1500,0,"i",i);
									GivePlayerXP(playerid,2);
									Abilitys[playerid][ScreamerZombieAb] = gettime();
								}



Re: How avoid ability from team attack - henkas - 14.02.2017

Ok i saw how you made it btw thanks!