Jump to content

playSound3D synced for every player


Mimimiguel

Recommended Posts

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.

Link to comment

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) 

Link to comment

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 )

Link to comment
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) ?

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