Headshot Problem
#4

Sure. The callback you're using has a parameter called 'weaponid'. It holds the ID of the weapon that is used to damage the player. You can use that parameter to see if it is a sniper that damaged the player or not.

Weapon ids: https://sampwiki.blast.hk/wiki/Weapons
The OnPlayerTakeDamage callback: https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Bodyparts: https://sampwiki.blast.hk/wiki/Body_Parts

Your code with that check:
PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart) {
    if ((
GetPlayerTeam(playerid) == NO_TEAM && GetPlayerTeam(issuerid) == NO_TEAM) || GetPlayerTeam(issuerid) != GetPlayerTeam(playerid)) {
        if (
bodypart == && ! g_Player[playerid][playerHelmet] && weaponid == 34) {
            
SetPlayerHealth(playerid0.0);
            
SendClientMessage(issueridCOLOR_ORANGE"Good job gangsta! You made a perfect headshot over that nigga! [+$3000 +1 Score]");
            
GivePlayerMoney(issuerid3000);
            
SetPlayerScore(issueridGetPlayerScore(issuerid) + 1);
            
            return 
0;
        }
    }
    return 
1;

I added the following:
PHP код:
if (bodypart == && ! g_Player[playerid][playerHelmet] && weaponid == 34)
// I added '&& weaponid == 34' 
Translation of the code:
Код:
IF bodypart equals 9 AND the player isn't wearing a helmet AND the weapon used to damage him is a sniper rifle: instant kill the player
Reply


Messages In This Thread
Headshot Problem - by HassanShah - 03.08.2016, 04:34
Re: Headshot Problem - by AndySedeyn - 03.08.2016, 05:08
Re: Headshot Problem - by HassanShah - 03.08.2016, 05:35
Re: Headshot Problem - by AndySedeyn - 03.08.2016, 05:38
Re: Headshot Problem - by HassanShah - 03.08.2016, 05:52

Forum Jump:


Users browsing this thread: 1 Guest(s)