[Tutorial] Anti-Teamshoot
#1

Hello,

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;
}
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.
Reply


Messages In This Thread
Anti-Teamshoot - by robintjeh - 12.02.2011, 18:44
Re: Anti-Teamshoot - by Grim_ - 12.02.2011, 18:47
Re: Anti-Teamshoot - by robintjeh - 12.02.2011, 18:52
Re: Anti-Teamshoot - by Grim_ - 12.02.2011, 18:55
Re: Anti-Teamshoot - by robintjeh - 12.02.2011, 18:57
Re: Anti-Teamshoot - by Grim_ - 12.02.2011, 19:04
Re: Anti-Teamshoot - by Kwarde - 12.02.2011, 19:24

Forum Jump:


Users browsing this thread: 1 Guest(s)