greentumbleweed Posted April 3, 2021 Share Posted April 3, 2021 client side function endVol() local position = guiScrollBarGetScrollPosition(Cock2)/100 local Number = math.random(1,37) muzik = playSound("sounds/"..tostring(Number)..".mp3") setSoundVolume(muzik, position) end addEvent("endvol",true) addEventHandler("endvol", getRootElement(), endVol) server side function muzikS( ) triggerClientEvent( source,"endvol", source ) end addEventHandler( "onRoundFinish", root, muzikS ) im trying to get the same random song to play on all clients this plays different per client Link to comment
SpecT Posted April 3, 2021 Share Posted April 3, 2021 Hey, Generate the random number from the server side and pass it to all the clients through the triggerClientEvent. This way everyone will hear the same sound. Link to comment
greentumbleweed Posted April 3, 2021 Author Share Posted April 3, 2021 3 minutes ago, SpecT said: Hey, Generate the random number from the server side and pass it to all the clients through the triggerClientEvent. This way everyone will hear the same sound. im not sure how to do this i knew i had to use random.math on server but idk how to pass it Link to comment
SpecT Posted April 3, 2021 Share Posted April 3, 2021 1 minute ago, greentumbleweed said: im not sure how to do this i knew i had to use random.math on server but idk how to pass it Client side: function endVol(soundNum) local position = guiScrollBarGetScrollPosition(Cock2)/100 muzik = playSound("sounds/"..tostring(soundNum)..".mp3") setSoundVolume(muzik, position) end addEvent("endvol",true) addEventHandler("endvol", root, endVol) Server side: function muzikS() local soundNum = math.random(1,37) triggerClientEvent( root,"endvol", resourceRoot, soundNum ) end addEventHandler( "onRoundFinish", root, muzikS ) It will be helpful to you to read the documentation for the function triggerClientEvent so you will know what argument is for what in future uses. Link to comment
greentumbleweed Posted April 3, 2021 Author Share Posted April 3, 2021 31 minutes ago, SpecT said: Client side: function endVol(soundNum) local position = guiScrollBarGetScrollPosition(Cock2)/100 muzik = playSound("sounds/"..tostring(soundNum)..".mp3") setSoundVolume(muzik, position) end addEvent("endvol",true) addEventHandler("endvol", root, endVol) Server side: function muzikS() local soundNum = math.random(1,37) triggerClientEvent( root,"endvol", resourceRoot, soundNum ) end addEventHandler( "onRoundFinish", root, muzikS ) It will be helpful to you to read the documentation for the function triggerClientEvent so you will know what argument is for what in future uses. i read the page for triggerClientEvent and seen the argument but i didnt realize you can just use a variable for that there thanks a lot Link to comment
SpecT Posted April 3, 2021 Share Posted April 3, 2021 1 hour ago, greentumbleweed said: i read the page for triggerClientEvent and seen the argument but i didnt realize you can just use a variable for that there thanks a lot Haha, you're welcome! 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