Dealman Posted March 31, 2013 Share Posted March 31, 2013 I'm working on a GUI for streaming music and for the most part I finally have the GUI working with most of it's features, at the moment, however, it is only working client-side. I am currently in the process of making it server-side so that the stream is played for all the clients currently in the server. And I've kind of run into a halt, I'm trying to output a message when a button in the GUI is clicked. I have it working to some extent(Message is successfuly output, but I can't concatenate any text.), but it's not really of any use as of now. What I want it to do is that when the button is clicked, the server will output a message, for example: is now Streaming: . I already have this working on the client-side version but I can't get it to work for the server. As I'm using a GUI, I can't use any nifty functions like guiGetText, since it's client-only. And I can't come up with a way to concatenate text from the client-side script of my resource. I've tried a few methods but I always end up with the Error "Attempt to concatenate global 'NameHere' ". I've searched around a bit regarding this but I can't find anything to help me. I believe I need to use export function but I can't figure out how to properly use it. I tried to be as descriptive as I can, but it's really hard to describe the issue at hand as well as what I want to achieve in detail when I don't even have any experience in programming... I would apprecaite any kind of help! Link to comment
xXMADEXx Posted March 31, 2013 Share Posted March 31, 2013 Are you trying to just stream the music for the person who wants to stream it, or are you trying to stream it to everyone on the server? Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 Are you trying to just stream the music for the person who wants to stream it, or are you trying to stream it to everyone on the server? It will stream for all the clients currently in the server, this is not what I need help with at the moment though. Since triggerClientEvent and triggerServerEvent really confuses me, I thought I'd start small first and start with getting it to output the messages first, and then move on to the somewhat bigger challenge of having events to start and stop the stream for clients and so on and so forth. Maybe it'll be easier to understand what I'm trying to do if I explain how the GUI works So I have this EditBox where the player can enter a URL, this URL is then streamed for all clients when a button in the GUI is clicked, this should also output a message to notify everyone who is streaming and what. Currently, in the client-side of things I am using guiGetText to fetch the URL inside the EditBox and then Stream it using playSound. The problem when I'm trying to output the message through the server-side is that I can't find a way to concatenate that URL. For example; outputChatBox("#CCFF00Streamster Server: "..streamURL,getRootElement(),250,0,0,true) That is what I've been playing around with, trying various methods but I always end up with an concatenate error. By the searching I've done so far, it would seem you can't concatenate text from another script, even though it's in the same folder - which I guess makes sense. So I'm trying to find another way to achieve this. Hopefully this made things a bit more clear, sorry about that Link to comment
Castillo Posted March 31, 2013 Share Posted March 31, 2013 Where is "streamURL" defined at? Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 Where is "streamURL" defined at? Currently it's being defined in client.lua, I can't find a way to to have it defined server-side since guiGetText is client-side only. Link to comment
Castillo Posted March 31, 2013 Share Posted March 31, 2013 And that outputChatBox is inside a function which is triggered from the client side? Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 And that outputChatBox is inside a function which is triggered from the client side? No, this one is server-side. This output is triggered when a player clicks the button to start the streaming. Link to comment
Castillo Posted March 31, 2013 Share Posted March 31, 2013 Which means that you execute the function that contains the outputChatBox from the client side using triggerServerEvent? Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 Which means that you execute the function that contains the outputChatBox from the client side using triggerServerEvent? Correct! Link to comment
Castillo Posted March 31, 2013 Share Posted March 31, 2013 Then, just send the result of guiGetText as an argument at triggerServerEvent and define it server side. Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 Something like this? Client: local streamURL = guiGetText(StreamEdit) triggerServerEvent("onStream",getLocalPlayer(),streamURL) Server: function startStream_Handler(player,streamURL) outputChatBox("#CCFF00Streamster Server: ",streamURL,getRootElement(),250,0,0,true) end addEvent("onStream",true) addEventHandler("onStream",root,playStream_Handler) Link to comment
Castillo Posted March 31, 2013 Share Posted March 31, 2013 function startStream_Handler(player,streamURL) Remove that "player" argument, since you are just passing the streamURL argument. Link to comment
Dealman Posted March 31, 2013 Author Share Posted March 31, 2013 Okay managed to get it to work! Thanks a lot Solidsnake Now to get some sleep and then to tackle some bigger challenges! Edit: Managed to get it to Stream the music for all clients, this is doing great so far! However, it seems like when people use really long URLs, it fails to output a message in the chat. I would assume there's a limit on number of characters? Is there a way to prevent this from happeing or a kind of workaround? 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