Jump to content

Headshot script


Minotaur

Recommended Posts

Hey all! I want a so headshot script that if no armor the player die if the player have armor his health go to half only with sniper. with another weapons like m4 you can kill the player with 4 headshot with also armor. with deagle if player have armor go his armor down with 1 headshot, with another headshot go his health to 10%. anybody can help me? thx and sorry for english

Link to comment

i created this but not working :S

function playerDamage_text ( attacker, weapon, bodypart, loss == 50 ) --when a player is damaged

if ( bodypart == 9 ) then -- if the body part is 9, i.e. the head

outputChatBox ( "Headshot!", getRootElement (), 255, 170, 0 ) --output "Headshot" into the chatbox

end

addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text )

Link to comment
  • Moderators

loss == 50  
 loss 

Those are parameters of the event, you can't change values of parameters inside the ( ).

You have to do that after that.

  
  
local playerDamage_text = function  ( attacker, weapon, bodypart, loss ) 
    if bodypart == 9 then  
        local health = getElementHealth(source)+loss-- get the health of the past. 
        local newHealth = health - 50--get the new health 
        if newHealth > 0 then 
            setElementHealth(source,newHealth) 
        else 
            killPed(source, attacker, weapon, bodypart) 
        end 
  
        outputChatBox ( "Headshot!", source, 255, 170, 0 )  
    end 
end 
addEventHandler ( "onPlayerDamage", root, playerDamage_text ) 
  

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