Jump to content

Only these weapons can trigger the headboom?


Recommended Posts

hello is it possible that only shotgun , sniper , combat shotgun can make the head go blow?

addEvent( "headboom", true ) 
function Zheadhit ( ped,attacker, weapon, bodypart) 
    if (getElementData (ped, "zombie") == true) then 
        killPed ( ped, attacker, weapon, bodypart ) 
        setPedHeadless  ( ped, true ) 
    end 
end 
addEventHandler( "headboom", getRootElement(), Zheadhit ) 
  

Link to comment

You could use the if operator to check the weapon:

  
addEvent( "headboom", true ) 
function Zheadhit ( ped,attacker, weapon, bodypart) 
 if weapon == WEAPONHERE or weapon == WEAPONHERE then 
    if (getElementData (ped, "zombie") == true) then 
        killPed ( ped, attacker, weapon, bodypart ) 
        setPedHeadless  ( ped, true ) 
    end 
 end 
end 
addEventHandler( "headboom", getRootElement(), Zheadhit ) 
  

But it is cleaner to use a table and use the if operator on the table like below:

  
local weaponsBoom = { 
   [WEAPONHERE] = true, 
} 
  
addEvent( "headboom", true ) 
function Zheadhit ( ped,attacker, weapon, bodypart) 
 if weaponsBoom[weapon] then 
    if (getElementData (ped, "zombie") == true) then 
        killPed ( ped, attacker, weapon, bodypart ) 
        setPedHeadless  ( ped, true ) 
    end 
 end 
end 
addEventHandler( "headboom", getRootElement(), Zheadhit ) 
  

Link to comment
does the weapon need to be an ID?

you can get weapons name by string. then you could use getWeaponIDFromName to get weapon id.

(I'm not sure that it works.)

local weaponsBoom = { 
   ["ak-47"] = true, -- example with ak-47 . 
} 
  
addEvent( "headboom", true ) 
function Zheadhit ( ped,attacker, weapon, bodypart) 
    local weaponName = getWeaponIDFromName(weaponsBoom[weapon]) 
    if weaponName then 
        if (getElementData (ped, "zombie") == true) then 
            killPed ( ped, attacker, weapon, bodypart ) 
            setPedHeadless  ( ped, true ) 
        end 
    end 
end 
addEventHandler( "headboom", getRootElement(), Zheadhit ) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...