Help Head Shot with sniper
#1

Код:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
   if (Shooter != INVALID_PLAYER_ID)
    {
        if (GetPlayerTeam(Target) == GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
        {

            new Float:hp;
            GetPlayerHealth(Target, hp);
            SetPlayerHealth(Target, hp + HealthLost);
            GameTextForPlayer(Shooter, "~r~Don't Team Kill!", 3000, 3);
        }
    }
    if ( Shooter != INVALID_PLAYER_ID )
    {
        if (GetPlayerTeam(Target) != GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
        {
            SetPlayerHealth(Target, 0);
            GameTextForPlayer(Target, "~r~Head Shot!", 3000, 3);
        }
    }
    return 1;
    }
how to add here only for sniper
Reply
#2

Add this under OnPlayerTakeDamage
PHP код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
{
        if (
GetPlayerTeam(Target) != GetPlayerTeam(Shooter))
        {
            
SetPlayerHealth(Target0);
            
GameTextForPlayer(Target"~r~Head Shot!"30003);
        }

Reply
#3

i only have

Quote:

public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (Shooter != INVALID_PLAYER_ID)
{
if (GetPlayerTeam(Target) == GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{

new Float:hp;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GameTextForPlayer(Shooter, "~r~Don't Team Kill!", 3000, 3);
}
}
if ( Shooter != INVALID_PLAYER_ID )
{
if (GetPlayerTeam(Target) != GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{
SetPlayerHealth(Target, 0);
GameTextForPlayer(Target, "~r~Head Shot!", 3000, 3);
}
}
return 1;
}

Reply
#4

Use OnPlayerTakeDamage callback !
Your script will detect all shoots as headshot !

In OnPlayerTake damage callback you can detect body part (for check issuerid shooted player's head or no)
And you can check weapon id
Reply
#5

i want only for sniper here

Quote:

public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (Shooter != INVALID_PLAYER_ID)
{
if (GetPlayerTeam(Target) == GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{

new Float:hp;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GameTextForPlayer(Shooter, "~r~Don't Team Kill!", 3000, 3);
}
}
if ( Shooter != INVALID_PLAYER_ID )
{
if (GetPlayerTeam(Target) != GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{
SetPlayerHealth(Target, 0);
GameTextForPlayer(Target, "~r~Head Shot!", 3000, 3);
}
}
return 1;
}

Reply
#6

You can't only you can put it under on player take damage
Reply
#7

create for me here

Quote:

public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (Shooter != INVALID_PLAYER_ID)
{
if (GetPlayerTeam(Target) == GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{

new Float:hp;
GetPlayerHealth(Target, hp);
SetPlayerHealth(Target, hp + HealthLost);
GameTextForPlayer(Shooter, "~r~Don't Team Kill!", 3000, 3);
}
}
if ( Shooter != INVALID_PLAYER_ID )
{
if (GetPlayerTeam(Target) != GetPlayerTeam(Shooter)) // check if the target is from the same team as the shooter.
{
SetPlayerHealth(Target, 0);
GameTextForPlayer(Target, "~r~Head Shot!", 3000, 3);
}
}
return 1;
}

Reply
#8

You are here to learn, not to just get everything done for you.
Here's a quick example, it'll kill the player if he's hit by a sniper.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(weaponid == 34) SetPlayerHealth(playerid, 0);
    return 1;
}
And you can put more code ofc.
Reply
#9

but i have errors with onplayertakedamage !!!!!!!!!!!!!!!!!!!!!!!!!
Reply
#10

show it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)