Sending data FROM server TO client and adding it to a ListBox help

Started by rulk, May 02, 2016, 04:43 PM

Previous topic - Next topic

rulk

Ok, as the title suggests, I am trying to send data FROM the server TO the client and add it to a ListBox.

Server Side Script

Client Side Script

I can manually add an item to the ListBox, but cannot add the streamed data to it.

so my question is, what do I have to do to add the streamed data as an item in the ListBox ?
We are all god's children.

Thijn

(I'm just assuming your server side script actually works, since player isn't defined in that function. I guess it's just an example. The culprit is in the client side)

The first thing that comes to mind to try is assigning a variable, then using that variable instead of the direct function call.
It doesn't make much sense why your code wouldn't work, but it's worth a shot...

local streamData = stream.ReadString();
Listbox.AddItem( streamData );

rulk

Quote from: Thijn on May 02, 2016, 04:52 PM(I'm just assuming your server side script actually works, since player isn't defined in that function. I guess it's just an example. The culprit is in the client side)

1. well noticed :-) yep, server side script works and it's just client side that's not working.

2. Already tried that, with no joy.
We are all god's children.

rulk

@Thijn  I appologise, your method has solved the issue. topic solved.
We are all god's children.

Thijn

I'd suggest @maxorator to take a look at this. Why would another variable be needed, but printing the function result directly would work fine?
This seems unintended behavior.

rulk

Ok, just for @maxorator  this is the working example;

This places a ListBox in the bottom right hand side of the screen and fills it with the following test data sent from the server
0 rulk
1 rulk
2 rulk

Server Side Script

Client Side Script

We are all god's children.

maxorator

Seems like intended behavior to me. The way streams work in most languages is that if you read something, the read position is automatically advanced, so if you have only one string in the stream, you can't read it twice in a row without resetting the stream.

.

Depends if it was sent as a reliable package. And I'm guessing that it's how they're sent.
.

Thijn

Quote from: maxorator on May 02, 2016, 06:48 PMSeems like intended behavior to me. The way streams work in most languages is that if you read something, the read position is automatically advanced, so if you have only one string in the stream, you can't read it twice in a row without resetting the stream.
That makes sense. So removing the print should've fixed this snippet?

KAKAN

Quote from: Thijn on May 02, 2016, 08:57 PM
Quote from: maxorator on May 02, 2016, 06:48 PMSeems like intended behavior to me. The way streams work in most languages is that if you read something, the read position is automatically advanced, so if you have only one string in the stream, you can't read it twice in a row without resetting the stream.
That makes sense. So removing the print should've fixed this snippet?
yeah. I got the point too, thanks, max. I had some problems understanding your test script which you cleared out.
oh no