Quest Posted January 22, 2008 Share Posted January 22, 2008 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
Jumba' Posted January 22, 2008 Share Posted January 22, 2008 Maybe you can post the script? =) Link to comment
Quest Posted January 22, 2008 Author Share Posted January 22, 2008 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
Jumba' Posted January 22, 2008 Share Posted January 22, 2008 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
Quest Posted January 22, 2008 Author Share Posted January 22, 2008 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
mabako Posted January 22, 2008 Share Posted January 22, 2008 make sure you don't have the headshot-resource loaded when trying your script, or any other resource which implents it. Link to comment
Quest Posted January 22, 2008 Author Share Posted January 22, 2008 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
Jumba' Posted January 22, 2008 Share Posted January 22, 2008 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
Quest Posted January 22, 2008 Author Share Posted January 22, 2008 addEvent "onPlayerHeadshot" Just the same as the headshot script that was released with the server download. I just added a few things, nothing has changed that should have this sort of effect. And I want it to kill the player. Link to comment
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