Jump to content

Damage sound


DarkByte

Recommended Posts

Posted
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 

Posted
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

Posted
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

Posted
Help?

wrong Argument you dont need to use player just put it like this

local sound = playSound("hit.mp3") 
setSoundVolume(sound, 0.5) 

Posted

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 ) 

Posted

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 ) 
  

Posted
addEventHandler("onClientPlayerDamage", root, 
function(attacker, weapon, bodypart) 
    if attacker and attacker == localPlayer and source ~= attacker then 
        playSound("hitmarker-sound.wav") 
    end 
end) 

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