DarkByte Posted October 14, 2015 Share Posted October 14, 2015 How to make a damage sound like when a player is shooting from a vehicle or a weapon and makes damage, how to play a sound when this happens? Link to comment
LoOs Posted October 14, 2015 Share Posted October 14, 2015 How to make a damage sound like when a player is shooting from a vehicle or a weapon and makes damage, how to play a sound when this happens? 'onClientWeaponFire' playSound Link to comment
DarkByte Posted October 14, 2015 Author Share Posted October 14, 2015 Script please. I wanna see and learn. Link to comment
TAPL Posted October 14, 2015 Share Posted October 14, 2015 How to make a damage sound like when a player is shooting from a vehicle or a weapon and makes damage, how to play a sound when this happens? 'onClientWeaponFire' playSound onClientWeaponFire is for custom weapons only, also he asked for damage which mean he need onClientPlayerDamage, not going to script instead of you ofc, learning is from this way: https://wiki.multitheftauto.com/wiki/Scripting_Introduction Link to comment
KariiiM Posted October 14, 2015 Share Posted October 14, 2015 How to make a damage sound like when a player is shooting from a vehicle You can use this function to check if the player is in a vehicle or not isPlayerInVehicle Link to comment
DarkByte Posted October 15, 2015 Author Share Posted October 15, 2015 function stopMinigunDamage ( attacker, weapon, bodypart ) if weapon then --if the weapon used was the minigun local sound = playSound("hit.mp3",player) setSoundVolume(sound, 50) end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage ) My script wont work Link to comment
Walid Posted October 15, 2015 Share Posted October 15, 2015 Help? wrong Argument you dont need to use player just put it like this local sound = playSound("hit.mp3") setSoundVolume(sound, 0.5) Link to comment
KariiiM Posted October 15, 2015 Share Posted October 15, 2015 From where you got this argument 'player'? Link to comment
Walid Posted October 15, 2015 Share Posted October 15, 2015 From where you got this argument 'player'? let him learn from his mistakes. he can find every thing here : playSound Link to comment
DarkByte Posted October 15, 2015 Author Share Posted October 15, 2015 Please help me fix it PLEASE. I cant make it. Link to comment
MisterQuestions Posted October 15, 2015 Share Posted October 15, 2015 getLocalPlayer() -> getRootElement() or root for everyone... check the weapon id, the miniguns id its: 38 Link to comment
Enargy, Posted October 16, 2015 Share Posted October 16, 2015 getLocalPlayer() -> getRootElement() or root for everyone...check the weapon id, the miniguns id its: 38 getRootElement and root are the same. Link to comment
KariiiM Posted October 16, 2015 Share Posted October 16, 2015 By the way, localPlayer == getLocalPlayer function stopMinigunDamage ( attacker, weapon, bodypart ) if weapon then --if the weapon used was the minigun local sound = playSound("hit.mp3") setSoundVolume(sound, 50) end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage ) Link to comment
TAPL Posted October 16, 2015 Share Posted October 16, 2015 Make sure you have the code on client side not server side. Link to comment
DarkByte Posted October 16, 2015 Author Share Posted October 16, 2015 yes its in client side Link to comment
DarkByte Posted October 16, 2015 Author Share Posted October 16, 2015 Meta <meta> <script src="hit_c.lua" type="client" cache="false" /> <file src="hitmarker-sound.wav" /> </meta> Lua --[[function wasted (killer, weapon, bodypart) local sound = playSound("hit.mp3") --Play wasted.mp3 from the sounds folder setSoundVolume(sound, 1) -- set the sound volume to 50% end addEventHandler("onClientPlayerDamage", localPlayer, wasted) addEventHandler("onClientVehicleDamage", localPlayer, wasted) ]] function stopMinigunDamage ( attacker, weapon, bodypart ) if weapon then --if the weapon used was the minigun local sound = playSound("hitmarker-sound.wav") setSoundVolume(sound, 50) end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopMinigunDamage ) addEventHandler ( "onClientVehicleDamage", getLocalPlayer(), stopMinigunDamage ) Link to comment
TAPL Posted October 16, 2015 Share Posted October 16, 2015 You want the damage sound when you damage other player or when you get damaged by other player? Link to comment
KariiiM Posted October 16, 2015 Share Posted October 16, 2015 (edited) Also check if the sound exist in file or not to declare it in the meta Edited October 16, 2015 by Guest Link to comment
DarkByte Posted October 16, 2015 Author Share Posted October 16, 2015 When i damage other player and when i damage other player using vehicle too. Link to comment
DarkByte Posted October 16, 2015 Author Share Posted October 16, 2015 sound exist in file? YEEES Link to comment
TAPL Posted October 16, 2015 Share Posted October 16, 2015 addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart) if attacker and attacker == localPlayer and source ~= attacker then playSound("hitmarker-sound.wav") end end) Link to comment
KariiiM Posted October 16, 2015 Share Posted October 16, 2015 sound exist in file? YEEES So declare the file name of the sound in the meta like that filename/sound.mp3 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