Anti team kill delay problem!!(rep+)
#1

pawn Код:
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;
}
This is my Anti Team kill function made with the help of OSPS!
The Bug is the lag/delay. When a Player shoots his own team mate The function gets the curr health and restores it with the HealthLost function. But if a player continuously shoots the team mate , Due to the lag the health restoration gets reduced then more and then more , The person dies due to Team Kill again!.

It's not that fast as it shud work.. I need a fast and relaible anti kill! Someone please help me to fix the code.

Is there anything i can do!?
Reply
#2

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

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

use
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
Reply
#5

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
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.
Yes ! But between a battle of five or ten player's .. This will be a Bug creating thing , That people will shoot their own team mate due to the lag in a crowd of player's, Then other teams will kill them and will create a Mess!
I was thinking to kick them by the way lol :S
Reply
#6

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

Quote:
Originally Posted by wildcookie007
Посмотреть сообщение
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.
Can you please tell me more about the function?? and the usage of it??

Quote:
Originally Posted by kizla
Посмотреть сообщение
use
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
Allright this seems okay but Weaponid? , I didnt understand the usage??
Can you give me a Code for one team using that brother?

Thanks for the replies!
Reply
#8

Quote:
Originally Posted by suhrab_mujeeb
Посмотреть сообщение
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 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;
}
LOL Brother. Try re-reading my script.. You will get to know why i just dont want one if over there.
Because in my TEAM_DEFINES Two teams r allies , So they cannot shooot them as well! Nor the player can shoot them
Reply
#9

https://sampwiki.blast.hk/wiki/SetPlayerTeam perhaps...?

EDIT -
I should probably reiterate that...

Basically, create new vars for when they become allies..then set the allies to the same team...I'm not sure if that's what you're looking for though
Reply
#10

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;
}
try something like this..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)