Bean666 Posted May 4, 2015 Posted May 4, 2015 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 )
Jaydan Posted May 4, 2015 Posted May 4, 2015 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 )
Enargy, Posted May 4, 2015 Posted May 4, 2015 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 )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now