SA-MP Forums Archive
Sniper/Rifle Head Shot Problem - 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: Sniper/Rifle Head Shot Problem (/showthread.php?tid=532984)



Sniper/Rifle Head Shot Problem - Meow22 - 21.08.2014

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID && gTeam[playerid] != gTeam[issuerid])
    {
        if(weaponid == 34 || weaponid == 33 && bodypart == 9)
        {
            new stringa[MAX_PLAYER_NAME+40];
            format(stringa, sizeof(stringa), "{00FFFF}[HEADSHOT]:{FFFFFF}%s{FFFF00}by{FFFFFF} %s", GetName(playerid), GetName(issuerid));
            SendClientMessageToAll(0xFFFF00FF,stringa), stringa = "\0"; GivePlayerScore(playerid,1);
            SetTimerEx("HeadshotKill", 500, false, "i", playerid);
        }
    }
    return 1;
}
forward HeadshotKill(playerid);
public HeadshotKill(playerid)
{
    SetPlayerHealth(playerid, 0);
    return 1;
}
If we shoot in any part of the Body.The Player Dies with 1 Shot.But I want it for only Head and Other Body 2 Shot kill .

Please Help


Re : Sniper/Rifle Head Shot Problem - S4t3K - 21.08.2014

if(weaponid == 34 || weaponid == 33 && bodypart == 9)

pawn Код:
if((weaponid == 34 || weaponid == 33) && (bodypart == 9))



AW: Sniper/Rifle Head Shot Problem - CIBERKILLER - 21.08.2014

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid == INVALID_PLAYER_ID || gTeam[playerid] == gTeam[issuerid])return 1;
    if(weaponid != 34 && weaponid != 33)return 1;
    if(bodypart != 9)return 1;
    new stringa[MAX_PLAYER_NAME+40];
    format(stringa, sizeof(stringa), "{00FFFF}[HEADSHOT]:{FFFFFF}%s{FFFF00}by{FFFFFF} %s", GetName(playerid), GetName(issuerid));
    SendClientMessageToAll(0xFFFF00FF,stringa), stringa = ""; GivePlayerScore(playerid,1);
    SetTimerEx("@HeadshotKill", 500, false, "i", playerid);
    return 1;
}
@HeadshotKill(id); @HeadshotKill(id){
  SetPlayerHealth(id, 0.0);
}
Try this source code a try!