SA-MP Forums Archive
Cops n Robbers Anti team kill - 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: Cops n Robbers Anti team kill (/showthread.php?tid=574261)



Cops n Robbers Anti team kill - kyriakos587 - 15.05.2015

Hi i have made anti team kill for CopsNRobbers with OnPlayerTakeDamage.

But is not work.

I want anti team kill for the teams CIA FBI POLICE.

For Civilians i dont want team kill.

Please help me.


Re: Cops n Robbers Anti team kill - arlindi - 15.05.2015

Here

This will help


Re: Cops n Robbers Anti team kill - Vince - 15.05.2015

Man, just use SetPlayerTeam. It has this stuff built in.


Re: Cops n Robbers Anti team kill - kyriakos587 - 15.05.2015

I try but i cant man.

See:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(GetPlayerTeam(issuerid) == GetPlayerTeam(playerid))
{
new Float:h;
GetPlayerHealth(playerid,h);
SetPlayerHealth(playerid,h+amount);
GameTextForPlayer(issuerid,"Don't shoot your team",2000,3);
return 1;
}else if(GetPlayerTeam(issuerid) == Civilians){
return 1;
}
}
return 1;
}


Re: Cops n Robbers Anti team kill - Konstantinos - 15.05.2015

Quote:

Players can not damage/kill players on the same team unless they use a knife to slit their throat.

So the check is not needed unless you want to check if the weapon is knife.


Re: Cops n Robbers Anti team kill - rappy93 - 15.05.2015

PHP код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost

   if ( 
Shooter != INVALID_PLAYER_ID )  
    {  
        if ( 
GetPlayerTeamTarget ) == GetPlayerTeamShooter ) ) // check if the victim is from the same team as the shooter.  
        
{  
  
            new 
Float:hp
            
GetPlayerHealth(Targethp); 
            
SetPlayerHealth(Targethp HealthLost); 
            
SetPlayerHealthShooter); 
            
SendClientMessageShooterCOLOR_RED"Team killing is not allowed!" );  
            
GivePlayerMoneyShooter, - 5000 );  
        } 
    } 
    return 
1

Try it like this and without changing any of the parameters at the top. Leave shooter and target and test it out.

Later Edit : Or just read what Konstantinos said .


Re: Cops n Robbers Anti team kill - kyriakos587 - 15.05.2015

@Konstantinos

I have made this now can you tell me if work?

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(GetPlayerTeam(issuerid) == GetPlayerTeam(playerid))
{
new Float:h;
GetPlayerHealth(playerid,h);
SetPlayerHealth(playerid,h+amount);
GameTextForPlayer(issuerid,"Don't shoot your team",2000,3);
return 1;
}else if(GetPlayerTeam(issuerid) == GetPlayerTeam(playerid) && GetPlayerTeam(playerid) == Civilians){
return 1;
}
}
return 1;
}


Re: Cops n Robbers Anti team kill - arlindi - 15.05.2015

Just use SetPlayerTeam
its more simple


Re: Cops n Robbers Anti team kill - kyriakos587 - 15.05.2015

Rappy i have try this but is work for all team.

This i want is to work for all teams but without civilians.


Re: Cops n Robbers Anti team kill - rappy93 - 15.05.2015

Although it would be better to just use SetPlayerTeam, give this a try.

PHP код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)  
{  
   if ( 
Shooter != INVALID_PLAYER_ID && GetPlayerTeam(Shooter) != Civilians)   
    {   
        if ( 
GetPlayerTeamTarget ) == GetPlayerTeamShooter ) ) // check if the victim is from the same team as the shooter.   
        
{   
   
            new 
Float:hp;  
            
GetPlayerHealth(Targethp);  
            
SetPlayerHealth(Targethp HealthLost);  
            
SetPlayerHealthShooter);  
            
SendClientMessageShooterCOLOR_RED"Team killing is not allowed!" );   
            
GivePlayerMoneyShooter, - 5000 );   
        }  
    }  
    return 
1;  

Now, if the shooter is not a civillian the script will execute, but if the shooter is a civillian the target will take daamge.