Mimimiguel Posted August 25, 2011 Posted August 25, 2011 Is there any way to do this? In my radio system only the one who's playing it can hear the sound, so, is there any way to make everyone hear it? Thanks
Fabio(GNR) Posted August 25, 2011 Posted August 25, 2011 To be clear, you want to create a sound in GTA world or doesnt it matter were the sound's located? If you really want to use 3D ( compare: https://wiki.multitheftauto.com/wiki/PlaySound3D , https://wiki.multitheftauto.com/wiki/PlaySound ) then create it for every player, everything you create client-side is only for the client your executing it "at". So only he/she will notice something created. Creating for everyone: trigger a client event for all players. If you reply, i'll go more detailed.
Mimimiguel Posted August 25, 2011 Author Posted August 25, 2011 Yes, please, i think i take the idea but im not sure of how can i create a sound for everyone in clientside starting of a gui event. The idea its to use the playSound3D function, so when another player gets nearly the sound he can hear it.
JR10 Posted August 25, 2011 Posted August 25, 2011 client: addEvent ( "playSoundForAllPlayers" , true) addEventHandler("playSoundForAllPlayers", root, function() playSound3D(...) end) And in server, use this whenever you want to play the sound. triggerClientEvent("playSoundForAllPlayers", root)
Mimimiguel Posted August 25, 2011 Author Posted August 25, 2011 Yes, but the event starts from a gui so what should i do? trigger the event from the gui to the server and then trigger it again to the client?
Mimimiguel Posted August 25, 2011 Author Posted August 25, 2011 Lets try it, ill post the results, thanks for the help.
Mimimiguel Posted August 26, 2011 Author Posted August 26, 2011 Well, the sync worked fine but I had another bug that i still couldnt solve: sound = {} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, sound, player ) if getElementData( player, "radio" ) == false then x, y, z = getElementPosition( veh ) sound[ player ] = playSound3D( sound, x, y, z, false ) setTimer( actualizarPosicionSonido, 50, 0, sound, veh ) setSoundMaxDistance( sound, maxdistance ) setElementData( player, "radio", true ) else stopSound( sound[ player ] ) sound[ player ] = nil setElementData( player, "radio", false ) end end ) Returns: Attempt to index local 'sound' ( a string value )
JR10 Posted August 26, 2011 Posted August 26, 2011 playSound3D( sound, x, y, z, false ) sound should be a table, and your using it in playSound3D, and you defined it as string before. Edit playSound3D and replace sound with the file path.
Mimimiguel Posted August 26, 2011 Author Posted August 26, 2011 playSound3D( sound, x, y, z, false ) sound should be a table, and your using it in playSound3D, and you defined it as string before. Edit playSound3D and replace sound with the file path. So instead of playSound3D( sound, x, y, z, false ) it should be for example playSound3D( "sound.mp3", x, y, z, false) ?
JR10 Posted August 26, 2011 Posted August 26, 2011 Yes. And if there is any local sound exept sound = {} remove it also setSoundMaxDistance( sound, maxdistance ) should be: setSoundMaxDistance( sound [ player ], maxdistance )
H5N1 Posted August 26, 2011 Posted August 26, 2011 My script (https://community.multitheftauto.com/index.php?p= ... ls&id=2585) use it, so you can look at code and learn how to synchronize it.
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