Help sniper problem
#1

how to add here headshot only for sniper weapon

pawn Код:
#include <a_samp>
 
/*-------------------------
HeadShot System by Peppe
The faster implementation of a headshot system in SA:MP.
This script requires the new version of SA:MP 0.3b.
 
http://www.pawnoitalia.forumfree.it
http://www.atlantisgaming.it
-------------------------*/

 
#define TIMER_INTERVAL 150
 
new
    maxPlayers;
 
public OnFilterScriptInit()
{
    maxPlayers = GetMaxPlayers();
    SetTimer("CheckHeadShot", TIMER_INTERVAL, 1);
    return 1;
}
 
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPVarInt(playerid, "Headshotted") == 1)
    {
        SetPVarInt(playerid, "Headshotted", 0);
        GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
        GameTextForPlayer(killerid, "~r~Headshott", 3000, 3);
    }
    return 1;
}
 
forward CheckHeadShot();
public CheckHeadShot()
{
    new
        index;
    for(new playerid; playerid < maxPlayers; playerid++)
    {
        if(IsPlayerConnected(playerid))
        {
            index = GetPlayerAnimationIndex(playerid);
            if(index == 1173 || index == 1175 || index == 1177 || index == 1178)
            {
                SetPVarInt(playerid, "Headshotted", 1);
                SetPlayerHealth(playerid, 0);
            }
        }
    }
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPVarInt(playerid, "Headshotted") == 1)
    {
        if(GetPlayerWeapon(killerid) == 34) // Sniper Rifle
        {
            SetPVarInt(playerid, "Headshotted", 0);
            GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
            GameTextForPlayer(killerid, "~r~Headshott", 3000, 3);
        }
    }
    return 1;
}
Reply
#3

now player don't have message headshoted
Reply
#4

Example - One-shot-kill sniper headshots
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        // One shot to the head to kill with sniper rifle
        SetPlayerHealth(playerid, 0.0);
    }
    return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Reply
#5

it can't work
Reply
#6

Try one of those, or each.

You could put your codes at only one, but it's better that way and should be synced
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    if(weaponid == WEAPON_SNIPER && bodypart ==  9) //If it's a sniper headshot
    {
        new Float:h; GetPlayerHealth(damagedid, h);
        if(h - amount < 0.1)//If that shot killed him
        {
            GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
        }
    }
}

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
    if(weaponid == WEAPON_SNIPER && bodypart ==  9) //If it's a sniper headshot
    {
        new Float:h; GetPlayerHealth(playerid, h);
        if(h - amount < 0.1)//If that shot killed him
        {
            //Do something
            GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)