Anti team-attack
#1

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 ?
Reply
#2

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

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

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

am using gteam
Reply
#6

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

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?
Reply
#8

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

Okay am gonna test it
Reply
#10

Just use setplayerteam yes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)