Jump to content

How do i change my weapon sounds?


Recommended Posts

For example :

addEventHandler("onClientPlayerWeaponFire", getRootElement(),  
function ( weapon, ammo, ammoInClip ) 
                local x,y,z = getElementPosition(source) 
                if weapon == 30 then  
                local sound = playSound3D("AK.mp3", x,y,z) 
                setSoundMaxDistance(sound,75) 
        end 
    end 
) 
  

Meta :

    
Edited by Guest
Link to comment

As far as i know you can use : onClientPlayerWeaponFire Add onClientRender Then getCameraMatrix After that : setCameraMatrix With + 0.5 Or something like that i hope you understand it and after that you have to spawn the player on the player position with getElementPosition And

getElementModel Then setCmaeraTraget After All That spawnPlayer You must use TriggerServerEvent Or setElementPosition At the client sided .

Link to comment

Instead of using setCameraMatrix I'd suggest to create fake explosion underneath the player.

https://wiki.multitheftauto.com/wiki/CreateExplosion

bool createExplosion ( float x, float y, float z, int theType [, bool makeSound = true, float camShake = -1.0, bool damaging = true ] ) 

When calling this function pass false as makeSound argument and damaging as false. This way player will not get damaged by the explosion and there won't be any sound but camera will shake.

Link to comment

5p where to put this line?

addEventHandler("onClientPlayerWeaponFire", getRootElement(), 
function ( weapon, ammo, ammoInClip ) 
                local x,y,z = getElementPosition(source) 
                if weapon == 22 then 
                local sound = playSound3D("hg.mp3", x,y,z) 
                setSoundVolume(sound,10) 
                setSoundMaxDistance(sound,75) 
        end 
    end 
) 

Link to comment
addEventHandler ( 'onClientPlayerWeaponFire', root, function ( weapon, ammo, ammoInClip ) 
    local x,y,z = getElementPosition ( source ) 
    if weapon == 22 then 
        local sound = playSound3D ( 'hg.mp3', x, y, z ) 
        setSoundVolume ( sound, 10 ) 
        setSoundMaxDistance ( sound, 75 ) 
        createExplosion ( x, y, z - 0.2, 2, false, true, false ) 
    end 
end ) 

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