Dealman Posted March 29, 2013 Share Posted March 29, 2013 Hello, I've been working on a GUI for streaming music for a while now and so far it's turning out fairly well. I have no experience programming with any language whatsoever so all the progress I have made so far has been entirely through trial and error. Currently with what I've got, I'm using ScrollBars to set the Volume and Playback Rate, and it's only supposed to set the volume and Playback Rate when their respective Button is clicked. I'm using onClientGUIClick as an EventHandler and thus, whenever I click any element it changes the Playback Rate and/or Volume. For example, I leave the Volume ScrollBar at 100% and the Playback Rate at 50%, if I click on the main window it will get the information from the scrollbars and trigger it. I lack the logic of a programmer so I can't really figure out a way to prevent this from happening. Currently this is the code I'm using for the Playback, it's pretty much identical for Volume: addEventHandler("onClientGUIClick",root,function() local scrollPosition = guiScrollBarGetScrollPosition(PlaybackScroll) if(source == PlaybackButton) then outputChatBox("#CCFF00Streamster: Playback Rate has been set to: #00CCFF"..tostring(scrollPosition).." %",250,0,0,true) setSoundSpeed(sound, scrollPosition/100) end end ) Another question I'd love answered would be how to make the sound play for other Clients as well, I'm well aware that I would have to use triggerClientEvent for this but it leaves me utterly confused as I'm using a Client-Side GUI(More specifically an EditBox) to fetch the URL to Stream as well to stream it when a Button is clicked. I know I'm new to this, so I'm sorry if I'm of nuisance but I'm really looking forward to finishing this eventually and as such I would appreciate any kind of help greatly! Link to comment
Guest Guest4401 Posted March 29, 2013 Share Posted March 29, 2013 Answer to your first problem: Are you sure that PlaybackButton is the button (not the window) which is supposed to be clicked? Answer to your second problem: You must triggerServerEvent and then triggerClientEvent back to all other players Link to comment
Dealman Posted March 30, 2013 Author Share Posted March 30, 2013 Answer to your first problem:Are you sure that PlaybackButton is the button (not the window) which is supposed to be clicked? Answer to your second problem: You must triggerServerEvent and then triggerClientEvent back to all other players Yeah, I'm sure. Thing is, even if I tell it to make a specific action when a specific source(In this case, a Button) is clicked, it doesn't really care. Sure, it performs the thing I want it to do, but if I click any other element inside the main GUI window, it will perform the same action. In other words, I could move the volume scroller to 50% and then left-click on the main window, and it will set the volume... Edit: Think I managed to find a way to fix the above mentioned problem, I will edit this reply soon. Edit2: Here's the solution I came up with: addEventHandler("onClientGUIClick",root,function() local scrollPosition = guiScrollBarGetScrollPosition(PlaybackScroll) local checkboxState = guiCheckBoxGetSelected(StreamCheckbox1) if(source == PlaybackButton and checkboxState == false) then outputChatBox("#CCFF00Streamster: Playback Rate has been set to: #00CCFF"..tostring(scrollPosition).." %",250,0,0,true) setSoundSpeed(sound, scrollPosition/100) elseif(source == PlaybackButton and checkboxState == true) then outputChatBox("#CCFF00Streamster: Playback Rate has been set to: #00CCFF"..tostring(scrollPosition*2).." %",250,0,0,true) setSoundSpeed(sound, scrollPosition/100*2) end end) Now I need to find a way to make this server-side. So far I have no idea how to achieve this, I've looked at triggerClientEvent and triggerServerEvent but they only leave me confused. How would I have the Server fetch the text inside the EditBox for a specific client, and then stream that text for all clients? 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