blurryshadow1 Posted March 21, 2011 Share Posted March 21, 2011 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
Castillo Posted March 21, 2011 Share Posted March 21, 2011 --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
blurryshadow1 Posted March 21, 2011 Author Share Posted March 21, 2011 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
blurryshadow1 Posted March 21, 2011 Author Share Posted March 21, 2011 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.. Link to comment
Kenix Posted March 21, 2011 Share Posted March 21, 2011 blurryshadow1 said: 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 Link to comment
blurryshadow1 Posted March 21, 2011 Author Share Posted March 21, 2011 volk-rus said: blurryshadow1 said: 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
Castillo Posted March 22, 2011 Share Posted March 22, 2011 I joined yesterday to help you to test it, and it worked so, case close. Link to comment
blurryshadow1 Posted March 22, 2011 Author Share Posted March 22, 2011 Solidsnake14 said: I joined yesterday to help you to test it, and it worked so, case close. yea... well i was planning on adding more kill sounds for different body parts... but i think ill hold off for now on my server.... it gets pretty time consuming... 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