Cops n Robbers Anti team kill
#1

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.
Reply
#2

Here

This will help
Reply
#3

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

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;
}
Reply
#5

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.
Reply
#6

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 .
Reply
#7

@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;
}
Reply
#8

Just use SetPlayerTeam
its more simple
Reply
#9

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)