How to make enable/disable Anti Team Kill
#1

Hello guys, how to make enable/disable Anti Team Kill ?

The code :
Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
   if ( Shooter != INVALID_PLAYER_ID )  
    {  
        if ( GetPlayerTeam( Target ) == GetPlayerTeam( Shooter ) ) // check if the victim is from the same team as the shooter.  
        {  
 
            new Float:hp;
            GetPlayerHealth(Target, hp);
            SetPlayerHealth(Target, hp + HealthLost);
            SetPlayerHealth( Shooter, 0 );
            SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );  
            GivePlayerMoney( Shooter, - 5000 );  
        }
    }
    return 1;
}
how to make enable/disable with command ?
Reply
#2

SetPlayerTeam to disable team kill
Reply
#3

Create a global variable

pawn Код:
new bool:teamkill = false;//by defaut teamfill is not allowed

CMD:teamkill(playerid,params[])
{
    new status;
    //Check that he is admin
    .
    .
    if(sscanf(params,"i",status)) return SendClientMessage(playerid,-1,"USAGE: /teamkill [status] 1=allowed | 0=banned");
    switch(status)
    {
        case 0: teamkill = false; break;
        case 1: teamkill = true;break;
        default: SendClientMessage(playerid,-1,"Only 1 and 0 allowed as staus");
    }
    return 1;
}

//Now in your code
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
   if ( Shooter != INVALID_PLAYER_ID )  
    {  
        if ( GetPlayerTeam( Target ) == GetPlayerTeam( Shooter ) ) // check if the victim is from the same team as the shooter.  
        {  
           if(teamkill == true) return 1; //If team kill is allowed.
            new Float:hp;
            GetPlayerHealth(Target, hp);
            SetPlayerHealth(Target, hp + HealthLost);
            SetPlayerHealth( Shooter, 0 );
            SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );  
            GivePlayerMoney( Shooter, - 5000 );  
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)