Jump to content
  • 0

Gun sounds


Grimaexreaper

Question

11 answers to this question

Recommended Posts

  • 0
Posted

Yes Jason. It's client side, I will copy paste my semi-messy but working script. Don't forget to load the gun sound file (for example sniper.wav) in Meta.

Ignore the commented stuff, all it does is make you go into slow motion when you shoot someone. It also blows up vehicles, I'm sure you know what res fiddycal is.

function firedFiddyCal(weapon, ammo, clipammo, x, y, z, element) 
    if ( weapon == 34) then -- sniper 
        local px, py, pz = getElementPosition(source) 
         
        local sound = playSound3D("sniper.wav", px, py, pz) 
        setSoundMaxDistance(sound, 150) 
         
        --if ( element and source == getLocalPlayer() and ( getElementType(element) == "vehicle" or getElementType(element) == "player" ) ) then -- we are the shooter 
                    --setGameSpeed(0.3) 
            --setTimer(setGameSpeed, 6000, 1, 1.0) 
  
            --triggerServerEvent("50cal", getLocalPlayer(), element) 
        --end 
         
         
        if ( element and getElementType(element) == "player" ) then -- make blood 
            fxAddBlood(x, y, z, 0, 0, 1, 1000, 1) 
            fxAddBlood(x, y, z, 1, 0, 0, 1000, 1) 
            fxAddBlood(x, y, z, 0, 1, 1, 1000, 1) 
            fxAddBlood(x, y, z, 1, 1, 1, 1000, 1) 
            fxAddBlood(x, y, z, 0, 1, 0, 1000, 1) 
        end 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", getRootElement(), firedFiddyCal) 

  • 0
Posted

There's a serious sound problem with that, when the sound stops, the sound doesn't get destroyed, so if you fire with the sniper 100 times in the area, go away from the area and go back, you will lag as hell.

  • 0
Posted
There's a serious sound problem with that, when the sound stops, the sound doesn't get destroyed, so if you fire with the sniper 100 times in the area, go away from the area and go back, you will lag as hell.

Could you fix the script then?

  • 0
Posted
  
local function firedFiddyCal(weapon, ammo, clipammo, x, y, z, element) 
    if ( weapon == 34) then -- sniper 
        local px, py, pz = getElementPosition(source) 
        
        local sound = playSound3D("sniper.wav", px, py, pz) 
        setSoundMaxDistance(sound, 150) 
        setTimer(destroyElement, 3000, 1, sound) 
         
        if ( element and getElementType(element) == "player" ) then -- make blood 
            fxAddBlood(x, y, z, 0, 0, 1, 1000, 1) 
            fxAddBlood(x, y, z, 1, 0, 0, 1000, 1) 
            fxAddBlood(x, y, z, 0, 1, 1, 1000, 1) 
            fxAddBlood(x, y, z, 1, 1, 1, 1000, 1) 
            fxAddBlood(x, y, z, 0, 1, 0, 1000, 1) 
        end 
    end 
end 
addEventHandler("onClientPlayerWeaponFire", root, firedFiddyCal) 
  

That's probably as efficient as it needs to be - a call to destroyElement is made 3 seconds after the shot is fired. Assuming that the sound is less than 3 seconds long, that should be enough.

  • 0
Posted

I've already tried custom car sounds and that's almost impossible excepting if you make a heavy resource for that :(, there was a feature suggested on bug tracker but seemed like the MTA team didn't take it as a possible feature...

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