StreetFighter163 Posted November 7, 2010 Posted November 7, 2010 I have a problem with playing sound: my sound effect is simply heard from everywhere, although i set the max distance to 30: addEvent("addShotFx",true) addEventHandler("addShotFx",getRootElement(), function(obj, vehicle,xoff,yoff,zoff) if vehicle then --if a vehicle was hit, create an explosion at the local coordinates local matrix = getElementMatrix(vehicle) local x1 = xoff * matrix[1][1] + yoff * matrix[2][1]+zoff * matrix[3][1]+matrix[4][1] local y1 = xoff * matrix[1][2] + yoff * matrix[2][2]+zoff * matrix[3][2]+matrix[4][2] local z1 = xoff * matrix[1][3] + yoff * matrix[2][3]+zoff * matrix[3][3]+matrix[4][3] createExplosion(x1,y1,z1,getElementData(obj,"explMgExplosion")) end local x,y,z = getElementPosition(obj) local matrix = getElementMatrix (obj) local ex = matrix[2][1] local ey = matrix[2][2] local ez = matrix[2][3] fxAddGunshot(x,y,z,ex,ey,ez) local sound = playSound3D("sounds/shot.wav",x,y,z) setSoundMaxDistance ( sound, 30 ) setSoundMinDistance ( sound, 0 ) end) this event is triggered by the server. It's a bit annoying to hear 15 players shooting who are miles away
12p Posted November 7, 2010 Posted November 7, 2010 addEvent("addShotFx",true) addEventHandler("addShotFx",getRootElement(), function(obj, vehicle,xoff,yoff,zoff) if vehicle then --if a vehicle was hit, create an explosion at the local coordinates local matrix = getElementMatrix(vehicle) local x1 = xoff * matrix[1][1] + yoff * matrix[2][1]+zoff * matrix[3][1]+matrix[4][1] local y1 = xoff * matrix[1][2] + yoff * matrix[2][2]+zoff * matrix[3][2]+matrix[4][2] local z1 = xoff * matrix[1][3] + yoff * matrix[2][3]+zoff * matrix[3][3]+matrix[4][3] createExplosion(x1,y1,z1,getElementData(obj,"explMgExplosion")) end local x,y,z = getElementPosition(obj) local matrix = getElementMatrix (obj) local ex = matrix[2][1] local ey = matrix[2][2] local ez = matrix[2][3] fxAddGunshot(x,y,z,ex,ey,ez) local sound = playSound3D("sounds/shot.wav",x,y,z) setSoundMaxDistance ( sound, 10 ) setSoundVolume ( sound, 1 ) end) And you should use MP3 sound, not WAV. WAV uses too much MB
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now