SA-MP Forums Archive
Anti Team-Kill Problem - 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-Kill Problem (/showthread.php?tid=605463)



Anti Team-Kill Problem - xXdaeminoXx - 19.04.2016

Hello guys,

i have problem with Anti Team-Kill between more teams.
Anti teamkill between USArmy and United Kingdom Forces or SAS and Spetsnaz.

Please give me answer, how to make multi anti team-kill between more teams. NOT between players in one team


Re: Anti Team-Kill Problem - zPain - 19.04.2016

SetPlayerTeam is the simplest way.

https://sampwiki.blast.hk/wiki/SetPlayerTeam


Re: Anti Team-Kill Problem - Saliim - 19.04.2016

Hi bro, use that :
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)//This callback is called when a player gives damage to another player.
{
if (GetPlayerTeam(playerid) != NO_TEAM && GetPlayerTeam(playerid) == GetPlayerTeam(damagedid)) {
    	GameTextForPlayer(playerid, "~w~Hey~>~~r~STOP KILL", 2000, 3);
}
return 1;
}



Re: Anti Team-Kill Problem - F1N4L - 19.04.2016

No give damage
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new Float:pHealth;
    GetPlayerHealth(damagedid, pHealth);
   
    if(damagedid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
            return SetPlayerHealth(damagedid, pHealth);
    }
    return 1;
}



Re: Anti Team-Kill Problem - xXdaeminoXx - 19.04.2016

I want Multi Anti team kill between 3 teams not 3 players. -_- i want to set Anit team killing between USA UK and Russia Teams. and SetPlayerTeam i never use because i dont have time to rebuild an all parts of Team System. Who have here somthing usefull ?


Re: Anti Team-Kill Problem - F1N4L - 19.04.2016

Quote:
Originally Posted by xXdaeminoXx
Посмотреть сообщение
I want Multi Anti team kill between 3 teams not 3 players. -_- i want to set Anit team killing between USA UK and Russia Teams. and SetPlayerTeam i never use because i dont have time to rebuild an all parts of Team System. Who have here somthing usefull ?
Change GetPlayerTeam for the variable that you define.
GetPlayerTeam is just one example.


Re: Anti Team-Kill Problem - xXdaeminoXx - 19.04.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
No give damage
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new Float:pHealth;
    GetPlayerHealth(damagedid, pHealth);
   
    if(damagedid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(playerid) == GetPlayerTeam(damagedid))
            return SetPlayerHealth(damagedid, pHealth);
    }
    return 1;
}
if(gTeam(playerid) == gTeam(damagedid) or if(TEAM_USA(playerid) == TEAM_UK(damagedid) ? i dont understand good english language. simple answer please :/


Re: Anti Team-Kill Problem - F1N4L - 19.04.2016

Example:

new gTeam[MAX_PLAYERS];

if(gTeam[playerid] == gTeam[damagedid])

Sorry my bad english


Re: Anti Team-Kill Problem - xXdaeminoXx - 19.04.2016

and anti teamkill between USA and UK ?


Re: Anti Team-Kill Problem - AdrianG - 20.04.2016

Use SetPlayerTeam in order to put someone in a team;
Use in
PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
     if(
hittype==BULLET_HIT_TYPE_PLAYER//hit a player
               
if(GetPlayerTeam(playerid)==GetPlayerTeam(hitid)) //the same team
                           
return 0;       // block the shot
     
return 1;