LT Uranus Posted October 19, 2011 Share Posted October 19, 2011 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
Castillo Posted October 19, 2011 Share Posted October 19, 2011 (edited) 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 October 20, 2011 by Guest Link to comment
LT Uranus Posted October 19, 2011 Author Share Posted October 19, 2011 yes i want this effect like someone is talking etc and people next to him can hear it ; with ur scripts i dont have any sounds playng at all when i type /c1 nothing happens Link to comment
TAPL Posted October 19, 2011 Share Posted October 19, 2011 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
Castillo Posted October 19, 2011 Share Posted October 19, 2011 Yep, I forgot to add the updateSoundPositions timer, but you shouldn't add it every time a sound creates. Link to comment
TAPL Posted October 19, 2011 Share Posted October 19, 2011 yep true, but you forgot a thing addEventHandler("createNewSound", should be addEventHandler("createNewSound", root, also less timer would be more better Link to comment
LT Uranus Posted October 20, 2011 Author Share Posted October 20, 2011 thanks both of you, for the help Link to comment
NotAvailable Posted October 20, 2011 Share Posted October 20, 2011 Why just not use attachElements? Link to comment
12p Posted October 20, 2011 Share Posted October 20, 2011 This question is already solved, Jesse. Link to comment
NotAvailable Posted October 21, 2011 Share Posted October 21, 2011 This question is already solved, Jesse. Im just giving a hint Link to comment
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