12.02.2011, 18:44
Hello,
This is an tut about how to make an anti-teamshoot. You will need this include: OnPlayerShootPlayer.
You can better change PlayerInfo[shooter][pTeam] to your own team system.
Explanation of code:
if(PlayerInfo[shooter][pTeam] == PlayerInfo[target][pTeam])
If the team of the shooter and the target is the same,
new Float:newhealth;
GetPlayerHealth(target, newhealth);
Get the players health.
newhealth = newhealth+sizeof(damage);
SetPlayerHealth(target, newhealth);
Calculate the current HP + the damage that was dealt and set it to before the shot.
else return 1;
If the teams aren't the same, do not change nothing at all.
Constructive critism is appreciated.
This is an tut about how to make an anti-teamshoot. You will need this include: OnPlayerShootPlayer.
pawn Code:
//Anti teamshoot by Robintjeh
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
if(PlayerInfo[shooter][pTeam] == PlayerInfo[target][pTeam])
{
new Float:newhealth;
GetPlayerHealth(target, newhealth);
newhealth = newhealth+sizeof(damage);
SetPlayerHealth(target, newhealth);
}
else return 1;
return 1;
}
Explanation of code:
if(PlayerInfo[shooter][pTeam] == PlayerInfo[target][pTeam])
If the team of the shooter and the target is the same,
new Float:newhealth;
GetPlayerHealth(target, newhealth);
Get the players health.
newhealth = newhealth+sizeof(damage);
SetPlayerHealth(target, newhealth);
Calculate the current HP + the damage that was dealt and set it to before the shot.
else return 1;
If the teams aren't the same, do not change nothing at all.
Constructive critism is appreciated.