public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
if ( Shooter != INVALID_PLAYER_ID )
{
if ( gTeam[Target] == gTeam[Shooter] ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_INDIA && gTeam[Shooter] == TEAM_INDPM ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_INDPM && gTeam[Shooter] == TEAM_INDIA ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_USA && gTeam[Shooter] == TEAM_USPM ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_USPM && gTeam[Shooter] == TEAM_USA ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_RUSSIA && gTeam[Shooter] == TEAM_RUSPM ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_RUSPM && gTeam[Shooter] == TEAM_RUSSIA ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_PAK && gTeam[Shooter] == TEAM_PAKPM ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_PAKPM && gTeam[Shooter] == TEAM_PAK ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_UK && gTeam[Shooter] == TEAM_UKPM ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[Target] == TEAM_UKPM && gTeam[Shooter] == TEAM_UK ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
}
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
I have no idea how to make faster timer, but i have a suggestion. Make something like freeze timer for shooter, when shooter shoots players he gets freezed for like 5 seconds, and he gets message "No Team Killing! Freezed for 5 Seconds!" Your timer should restore the victims health in time then.
|
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
if ( Shooter != INVALID_PLAYER_ID )
{
if ( gTeam[Target] == gTeam[Shooter] ) // check if the victim is from the same team as the shooter.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GetPlayerArmour(Target, ap);
SetPlayerArmour(Target, ap + ArmourLost);
SendClientMessage( Shooter, COLOR_RED, "Team killing is not allowed!" );
}
}
return 1;
}
erm..why don't you just use 0.3d function instead of 90% accurate user made, and besides you can set the same team for no team killing.
|
use
pawn Код:
|
You cannot control the time interval between which the player sends data to the server. The fastest of them can be OnPlayerUpdate but still needs the player to send the update to the server. Try using a better script. The script you created is pointless. It checks the gTeam on every "if". Try this simpler code (Your code modified):
pawn Код:
|
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if ( playerid != INVALID_PLAYER_ID )
{
if ( gTeam[damagedid] == gTeam[playerid] ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_INDIA && gTeam[playerid] == TEAM_INDPM ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_INDPM && gTeam[playerid] == TEAM_INDIA ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_USA && gTeam[playerid] == TEAM_USPM ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_USPM && gTeam[playerid] == TEAM_USA ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_RUSSIA && gTeam[playerid] == TEAM_RUSPM ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_RUSPM && gTeam[playerid] == TEAM_RUSSIA ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_PAK && gTeam[playerid] == TEAM_PAKPM ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_PAKPM && gTeam[playerid] == TEAM_PAK ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_UK && gTeam[playerid] == TEAM_UKPM ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
if ( gTeam[damagedid] == TEAM_UKPM && gTeam[playerid] == TEAM_UK ) // check if the victim is from the same team as the playerid.
{
new Float:hp;
new Float:ap;
GetPlayerHealth(damagedid, hp);
SetPlayerHealth(damagedid, hp + amount);
GetPlayerArmour(damagedid, ap);
SetPlayerArmour(damagedid, ap + amount);
SendClientMessage( playerid, COLOR_RED, "Team killing is not allowed!" );
}
}
return 1;
}