Jump to content

Headshot Issue


Quest

Recommended Posts

I am having an issue with my Headshot script repeating headshots. Meaning, when a player gets nailed in the head SOMETIMES he dies after spawn. I am trying to get a work around for this. Anyone aware or have one ? I think I could do this if I could create a bodyshot hit counter, this would count the number of time thePlayer has been hit. This is driving me mad, I just haven't been able to get this to work properly. Anyone else have this ?

Link to comment
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart) 
        if bodypart == 9 then 
            local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon) 
            if result == true then 
                setElementHealth( source, 0 ) 
                killer = attacker 
                outputChatBox ("You nailed "..getClientName(source).." in the head!!", attacker) 
                outputChatBox ("You were shot in the head by"..getClientName(attacker).."!", source) 
                setPlayerMoney(attacker, getPlayerMoney( attacker ) + 2000 ) 
            end 
        end 
    end) 

Link to comment

try this, i replaced setElementHealth with killPlayer

  
addEventHandler("onPlayerDamage", getRootElement(), 
    function (attacker, weapon, bodypart) 
        if bodypart == 9 then 
            local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon) 
            if result == true then 
                killPlayer (source, attacker, weapon) 
                killer = attacker 
                outputChatBox ("You nailed "..getClientName(source).." in the head!!", attacker) 
                outputChatBox ("You were shot in the head by"..getClientName(attacker).."!", source) 
                setPlayerMoney(attacker, getPlayerMoney( attacker ) + 2000 ) 
            end 
        end 
    end) 
  

btw, is the

  
local result = triggerEvent("onPlayerHeadshot", source, attacker, weapon) 
            if result == true then 
  

part neccesary? can't you just go to killPlayer if the shot bodypart == 9?

and is there a onPlayerHeadshot event? searched the wiki, but i couldn't find it =/

Link to comment

Sorry about that I forgot to add the custom event that I added, addEvent( "onPlayerHeadshot" ). I have tried both, killPlayer and setPlayerHealth. They have the same result. It seems like the servers want to continue counting the hits after the player is already dead. I have even at one point mad a check to see if the isPlayerDead and had an else statement and no go.

Link to comment

Ohhhhh, I do have it in my server config to load at start up. So if I remove it from startup and restart the server it might stop it?

EDIT* Sorry misread that I think. There are no other Headshit resources running. Just mine. Its odd, I removed the item from the startup and everything can't put my finger on it.

Link to comment
Sorry about that I forgot to add the custom event that I added, addEvent( "onPlayerHeadshot" ). I have tried both, killPlayer and setPlayerHealth. They have the same result. It seems like the servers want to continue counting the hits after the player is already dead. I have even at one point mad a check to see if the isPlayerDead and had an else statement and no go.

Wait, show me the onPlayerHeadshot event and the function that it calls.

actually, cant you just remove that part? It's not like it's really needed to kill the player.

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