Jump to content
  • 0

playSound3d


Deixell

Question

local weapFunc = { [26]={nil,0.4},[30]={'ak1',0.2},[31]={'M4',0.15},[29]={'MP5',0.1},[34]={'SNIPER',0.5},[24]={'deagle',0.05},[25]={'Shotgun',0.3},[27]={'Shotgun',0.3} }
local localPlayer = getLocalPlayer ( )
 
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
local x,y,z = getPedWeaponMuzzlePosition ( source )
if(getDistanceBetweenPoints3D(x,y,z,px,py,pz) < 80) then
	if weapFunc[weapon] then
		if weapFunc[weapon][1]  then 
			playSound3D ( "sounds/"..weapFunc[weapon][1]..".ogg")
		end	
		if(source == localPlayer) then
			createExplosion ( x,y,z + 10,12,false,weapFunc[weapon][2],false)
		end
	end
end
end
 
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), onClientPlayerWeaponFireFunc )

This command should play the sound for everyone in range but only the one who shoots hear this sounds.

Link to comment

3 answers to this question

Recommended Posts

  • 0

local weapFunc = { [26]={nil,0.4},[30]={'ak1',0.2},[31]={'M4',0.15},[29]={'MP5',0.1},[34]={'SNIPER',0.5},[24]={'deagle',0.05},[25]={'Shotgun',0.3},[27]={'Shotgun',0.3} }
local localPlayer = getLocalPlayer ( )
 
function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement )
  local x,y,z = getPedWeaponMuzzlePosition ( source )
  local x,y,z = getPedWeaponMuzzlePosition ( localPlayer )
  if(getDistanceBetweenPoints3D(x,y,z,px,py,pz) < 80) then
     if weapFunc[weapon] then
        if weapFunc[weapon][1]  then 
           playSound3D ( "sounds/"..weapFunc[weapon][1]..".ogg")
        end   
        if(source == localPlayer) then
           createExplosion ( x,y,z + 10,12,false,weapFunc[weapon][2],false)
        end
     end
  end
end
 
addEventHandler ( "onClientPlayerWeaponFire", getRootElement(), onClientPlayerWeaponFireFunc )

The idea is that custom sound should play when somebody else is shooting, it plays, yes, but not clear, with.. crackles. However it plays well for local player (when he shoots).

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