Minor help.(REPLY Please) - 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: Minor help.(REPLY Please) (
/showthread.php?tid=401393)
Minor help.(REPLY Please) -
Strier - 22.12.2012
Can someone please explain me, how to make an anti-team attack system.. I got the teams, i got everything simply i gave up at trying to make it so i had to post here, if anybody could help me that'd be awesome..
Re: Minor help.(REPLY Please) -
DaRk_RaiN - 22.12.2012
Well there are a lot of ways, here are the easiest
In case you didn't use the fonctions SetPlayerTeam and GetPlayerTeam,and used gTeam instead use them, its the best way to prevent Team Kill
Example:
pawn Код:
OnPlayerSpawn(playerid)
{
if(gTeam[playerid] == TEAM_ONE)
{
SetPlayerTeam(playerid, 1);
}
else if (gTeam[playerid] == TEAM_TWO)
{
SetPlayerTeam(playerid, 2);
}
//ect..................
return 1;
}
And there is an other simple way to do it using OnPlayerTakeDamage CallBack
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID && GetPlayerTeam(playerid) == GetPlayerTeam(issuerid))return 1;
return 1;
}
And in case you use gTeam
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID && gTeam[playerid] == gTeam[issuerid])return 1;
return 1;
}