SA-MP Forums Archive
Anti 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: Anti team-attack (/showthread.php?tid=442872)



Anti team-attack - TheSnaKe - 09.06.2013

Hello, i have have got a GW Server (Gang Wars) Server.
I need to add anti-team attack / anti-team kill.
Can anyone help me ?


Re: Anti team-attack - Guest123 - 09.06.2013

hmm i give you example

pawn Code:
public OnPlayerUpdate(playerid)
{
  if(GetPlayerSkin(playerid) == 280 || 281 || 282)//police skin
   {
   SetPlayerTeam(playerid,1);// if player use police skin, they are team 1
   }
  if(GetPlayerSkin(playerid) == 28)//bmydrug skin
   {
   SetPlayerTeam(playerid,2);// if player use terorrist skin, they are team 2
   }
  return 1;
}
put this under OnGameModeInit()

pawn Code:
public OnGameModeInit()
{
    EnableVehicleFriendlyFire();
    return 1;
}



Re: Anti team-attack - Facerafter - 09.06.2013

OR, just use the OnPlayerTakeDamage public.
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
Get the team id of the issuerid and if its the same as the teamid of the playerid, you can do
pawn Code:
if(issuerid != INVALID_PLAYER_ID)
{
new Float:health, Float:newhealth;
health = GetPlayerHealth(playerid, health);
newhealth = health += amount;
SetPlayerHealth(playerid, newhealth);
}
There could be some mistakes made this really quick, but i think it should work.


Re: Anti team-attack - Vince - 09.06.2013

I don't see why you'd need either of those. Guest123 is partially correct with SetPlayerTeam, but OnPlayerUpdate is severe overkill. Setting the team once on spawn is enough.


Re: Anti team-attack - TheSnaKe - 09.06.2013

am using gteam


Re: Anti team-attack - Facerafter - 09.06.2013

Quote:
Originally Posted by Vince
View Post
I don't see why you'd need either of those. Guest123 is partially correct with SetPlayerTeam, but OnPlayerUpdate is severe overkill. Setting the team once on spawn is enough.
Yes, but i think you or i are reading the first post wrong.
I thought he asks to create a anti friendly fire system. (I Assumed he already got something like that what defines the players team)

I thought he needed something like this :
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[playerid][gTeam] == PlayerInfo[playerid][gTeam])
        {
            new Float:health, Float:newhealth;
            health = GetPlayerHealth(playerid, health);
            newhealth = health += amount;
            SetPlayerHealth(playerid, newhealth);
        }
    }
}



Re: Anti team-attack - TheSnaKe - 09.06.2013

Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[playerid][gTeam] == PlayerInfo[playerid][gTeam])
        {
            new Float:health, Float:newhealth;
            health = GetPlayerHealth(playerid, health);
            newhealth = health += amount;
            SetPlayerHealth(playerid, newhealth);
        }
    }
}
i must add this under OnPlayerDeath? or i must add this anywhere in the gamemode?


Re: Anti team-attack - Aly - 09.06.2013

You have to add something like this to OnPlayerSpawn:

if(PlayerInfo[playerid][pMember] == 1) gTeam[playerid] = 1;
or with skins: if(GetPlayerSkin(playerid) == 121) gTeam[playerid] = 1;
You have to do this for all the gangs.

After that you use OnPlayerTakeDamage like Facerafter said:
pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(gTeam[playerid] == gTeam[issuerid])
        {
            new Float:health, Float:newhealth;
            health = GetPlayerHealth(playerid, health);
            newhealth = health += amount;
            SetPlayerHealth(playerid, newhealth);
        }
    }
}



Re: Anti team-attack - TheSnaKe - 09.06.2013

Okay am gonna test it


Re: Anti team-attack - dEcooR - 09.06.2013

Just use setplayerteam yes