Jump to content

playSound3D synced for every player


Mimimiguel

Recommended Posts

Posted

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.

Posted

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) 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

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 )

Posted
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) ?

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