Jump to content

playSound3D


LT Uranus

Recommended Posts

server side

  
function zalu1 () 
triggerClientEvent ( "ads1", getRootElement() ) 
end  
addCommandHandler ( "c1", zalu1 ) 
  

client side

  
function copythat ( player ) 
            local player = getLocalPlayer ( ) 
        local Zx,Zy,Zz = getElementPosition( player ) 
                local ef3 = playSound3D("sounds/copythat.wav", Zx, Zy, Zz, false) 
        setSoundMaxDistance(ef3, 15) 
                setSoundVolume(ef3, 0.5)                  
end 
addEvent( "ads1", true ) 
addEventHandler( "ads1", getRootElement(), copythat ) 
  

hey everyone ,

so i want to make "voice commands" with typing /.. ;

anyway i got this - i can hear it 3D sound myself but the people next to me - can't hear it in 3D , also it plays same sound for all players while it should be only 3D in specific location,idkn should it be attached to that player somehow or saving then uplaoding player's cordinates data would help, how it could be realy 3D like this only attached to command using players ( moving or idle ) location ? =

  
function onResourceStart() 
    local sound = playSound3D("sounds/song.mp3", 373.14, -125.21, 1001, true)  
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onResourceStart) 
  

thanks :)

Link to comment

I don't get what do you want, you want to play a sound around the player who typed /c1 command? if so try this:

-- client side:

local sounds = {} 
  
addEvent("createNewSound",true) 
addEventHandler("createNewSound",root, 
function (player) 
      local x, y, z = getElementPosition(player) 
      sounds[player] = playSound3D("sounds/copythat.wav", x, y, z, false) 
end) 
  
function updateSoundPositions() 
     for player, sound in pairs(sounds) do 
           if isElement(player) and isElement(sound) then 
                setElementPosition(sound, getElementPosition(player)) 
           end 
     end 
end 
setTimer(updateSoundPositions,2000,0) 

-- server side:

addCommandHandler("c1", 
function (player) 
     triggerClientEvent("createNewSound",getRootElement(),player) 
end) 

Edited by Guest
Link to comment
local sounds = {} 
  
addEvent("createNewSound",true) 
addEventHandler("createNewSound", root, 
function (player) 
      local x, y, z = getElementPosition(player) 
      sounds[player] = playSound3D("sounds/copythat.wav", x, y, z, false) 
      setTimer(updateSoundPositions,100,0) 
end) 
  
function updateSoundPositions() 
     for player, sound in pairs(sounds) do 
           if isElement(player) and isElement(sound) then 
                setElementPosition(sound, getElementPosition(player)) 
           end 
     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...