Jump to content

Problem with Headshot!


ramzi

Recommended Posts

Hi guys,i have a little problem in my headshot script,i don't want it with all weapons.

i just want it with sniper only.here is the lua:

addEvent "onPlayerHeadshot" 
  
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart, loss) 
        if bodypart == 9 then 
            local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) 
            if result == true then 
                killPed(source, attacker, weapon, bodypart) 
            end 
        end 
    end 
) 

Link to comment

Try this:

addEvent "onPlayerHeadshot" 
  
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart, loss) 
        if ( bodypart == 9 ) and ( weapon == 34 ) then 
            local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) 
            if ( result ) then 
                killPed(source, attacker, weapon, bodypart) 
            end 
        end 
    end 
) 

Link to comment
  • MTA Team
addEvent("onPlayerHeadshot",true) 
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart, loss) 
        if bodypart == 9 and weapon == 34 then 
            local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon, loss) 
            if result == true then 
                killPed(source, attacker, weapon, bodypart) 
            end 
        end 
    end 
) 

Anyway you are not showing us the "onPlayerHeadshot" function.

That could also be a problem.

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...