SA-MP Forums Archive
Help Head Shot with sniper - 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: Help Head Shot with sniper (/showthread.php?tid=559860)



Help Head Shot with sniper - Mijata - 25.01.2015

Код:
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


Re: Help Head Shot with sniper - nezo2001 - 25.01.2015

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);
        }




Re: Help Head Shot with sniper - Mijata - 25.01.2015

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




Re: Help Head Shot with sniper - M4D - 25.01.2015

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


Re: Help Head Shot with sniper - Mijata - 25.01.2015

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




Re: Help Head Shot with sniper - nezo2001 - 25.01.2015

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


Re: Help Head Shot with sniper - Mijata - 25.01.2015

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




Re: Help Head Shot with sniper - CalvinC - 25.01.2015

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.


Re: Help Head Shot with sniper - Mijata - 25.01.2015

but i have errors with onplayertakedamage !!!!!!!!!!!!!!!!!!!!!!!!!


Re: Help Head Shot with sniper - nezo2001 - 25.01.2015

show it