How to make enable/disable 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: How to make enable/disable Anti Team Kill (
/showthread.php?tid=421065)
How to make enable/disable Anti Team Kill -
Broker - 08.03.2013
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 ?
Re: How to make enable/disable Anti Team Kill -
DaTa[X] - 08.03.2013
SetPlayerTeam to disable team kill
Re: How to make enable/disable Anti Team Kill -
[MM]RoXoR[FS] - 08.03.2013
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;
}