Jump to content

Damage sound


DarkByte

Recommended Posts

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

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

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

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