Jump to content
  • 0

Gun sounds


Grimaexreaper

Question

11 answers to this question

Recommended Posts

  • 0

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) 

Link to comment
  • 0
  
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.

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