Jump to content

Headshot problem.(Solved)


ramzi

Recommended Posts

Posted (edited)

Hi guys,i have over here a simple headshot script which i've downloaded from the community:

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 == true then 
                killPed(source, attacker, weapon, bodypart) 
                setPedHeadless( source, true ) 
                setTimer( BackUp, 900, 1, source ) 
            end 
        end 
    end 
) 
    function BackUp( source )    
    if getElementType ( source ) == "player" then 
        setPedHeadless ( source, false ) 
    end 
end 

The problem is that i want the "part 9" to be taken off becuase when i shoot the head,the player dies but the head still in its place ,thank you.

Edited by Guest
Posted

Just remove line 9 (timer) from the code that you posted and add this code at bottom

addEventHandler("onPlayerSpawn", root, function () setPedHeadless( source, false) end ) 

Posted
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 == true then 
                killPed(source, attacker, weapon, bodypart) 
                setPedHeadless( source, true ) 
                addEventHandler("onPlayerSpawn", root, function () setPedHeadless( source, false) end ) 
            end 
        end 
    end 
) 
    function BackUp( source )    
    if getElementType ( source ) == "player" then 
        setPedHeadless ( source, false ) 
    end 
end 

I did like this and it stills not working.

Posted

I guess you start the headshot script that already exist, rename is like this in your Meta

  

    "Headshot" type="script" version="1.0.0" /> 
    

with a big H and 2st o like this Headshoot

Posted
The script works fine for me, tested it.. So dont understand why it didnt work for you

Can i ask for something else please?i want to ristrict it to a team,can u help me?

Posted

Try this one

  
addEvent "onPlayerHeadshot" 
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart, loss) 
    if getElementType ( attacker ) == "player" then 
        if bodypart == 9 and weapon == 34 then 
            local HSteam = getPlayerTeam(attacker) 
            if HSteam and getTeamName(HSteam)=="YOUR GANG NAME HERE" then        
                local result = triggerEvent("onPlayerHeadshot",source, attacker, weapon, loss) 
                if result == true then                       
                  killPed(source, attacker, weapon, bodypart) 
                  setPedHeadless( source, true )                
                  addEventHandler("onPlayerSpawn", root, function () setPedHeadless( source, false) end )  
                end                
            end          
        end                                      
    end 
    end  
) 
    function BackUp( source )   
    if getElementType ( source ) == "player" then 
        setPedHeadless ( source, false ) 
    end 
end 
  

Posted
  
local restrict_team = "team name here" 
  
addEvent("onPlayerHeadshot", true ) 
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart, loss) 
    if getElementType ( attacker ) == "player" then 
        if bodypart == 9 and weapon == 34 then 
            local HSteam = getPlayerTeam(attacker) 
            if HSteam == getTeamFromName( restrict_team ) then       
                local result = triggerEvent("onPlayerHeadshot",source, attacker, weapon, loss) 
                if result == true then                      
                  killPed(source, attacker, weapon, bodypart) 
                  setPedHeadless( source, true )                
                  addEventHandler("onPlayerSpawn", root, function () setPedHeadless( source, false) end ) 
                end               
            end         
        end                                     
    end 
    end  
) 
    function BackUp( source )   
    if getElementType ( source ) == "player" then 
        setPedHeadless ( source, false ) 
    end 
end 
  

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