Jump to content

Headshot Sound Effect


Recommended Posts

im trying to combine the code where if you shoot the head its a one hit kill with another code that plays a sound whenever you get a headshot kill but i dont exactly know how to combine them can someone give me a hand?

this one

function headShot(attacker, weapon, bodypart, loss) 
 if (bodypart == 9) then 
  killPed(source, attacker, weapon, bodypart)  
  if (weapon == 25) or (weapon == 26) or (weapon == 27) then--//Åñëå âûñòðåë èç äðîáîâèêîâ òî, ñðûâàåì ãîëîâó. 
   setPedHeadless(source, true)  
  end 
 end 
end 
addEventHandler("onPlayerDamage", getRootElement(), headShot) 

combined with this

function startMySound() 
    sound = playSound( "headshot.mp3", false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), startMySound ) 

ive edited the second one to try and fit the needs for combining but i dont know if im doing it right at all...

i want to try and get it right the first time cause i rarely have anyone on my server so i can test stuff like this...

Link to comment

--server side code (define type="server" in meta.xml)

function headShot(attacker, weapon, bodypart, loss) 
 if (bodypart == 9) then 
  killPed(source, attacker, weapon, bodypart) 
  triggerClientEvent(attacker,"playSound",attacker) 
  if (weapon == 25) or (weapon == 26) or (weapon == 27) then--//Åñëå âûñòðåë èç äðîáîâèêîâ òî, ñðûâàåì ãîëîâó. 
   setPedHeadless(source, true) 
  end 
 end 
end 
addEventHandler("onPlayerDamage", getRootElement(), headShot) 
  

--client side code (define type="client" in meta.xml)

addEvent("playSound",true) 
addEventHandler("playSound",getRootElement(), 
function () 
sound = playSound( "headshot.mp3", false ) 
end) 

Link to comment

ok so what i did was made two .lua files and put the 1st code on one file and the second code on the other file. then i created a meta.xml file and got this

<meta> 
    <info gamemodes="gang" type="script" name="killsounds" author="blurryshadow1" version="1.0.0" description="killsounds" /> 
    <script src="headshot.lua" type="server" /> 
    <script src="headshot2.lua" type="client" /> 
    <file src="headshot.mp3" /> 
</meta> 

i did it right?

Link to comment
ah ok.... well the only thing left to do now is test it. to know for sure if it works... looks like ill have to wait awhile for someone to join.. :|

use zombie script

ahh oh yea your right!!! thanks... now i dont have to keep asking people haha..

edit: nvm it doesnt work on the zombies...

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