Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 02 May 2012 07:22 PM |
Is there a way to...
A) Run a local script once, and then have it run, even when the player respawns.
B) If you save stuff in _G. w/ a local script, does that negate the need to have values for your stats that aren't going to be communicating with the server.
C) Is there an effective way to communicate server to client. |
|
|
| Report Abuse |
|
|
|
| 02 May 2012 07:29 PM |
A) No. B) No. Well, yes, but not if you want to do it the right way. C) No. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 02 May 2012 07:30 PM |
| How would you address the problem of C then. That's the main thing. |
|
|
| Report Abuse |
|
|
|
| 02 May 2012 07:33 PM |
A)Yes; if not _G.ThisScraptRan then --assuming you have it in starterpack _G.ThisScraptRan=true script.Disabled=true else script:Destroy() end --Please note, you will have to account for a lot of errors that can occur on respawn
|
|
|
| Report Abuse |
|
|
|
| 02 May 2012 07:37 PM |
Client->Server I would have a script with a string value for each player in it+listening event for .changed and use http://wiki.roblox.com/index.php/RbxUtility_(Library) to transfer tables as strings.
Server->Client String value parented to player, same thing as above. |
|
|
| Report Abuse |
|
|
Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 02 May 2012 08:04 PM |
A simple way to do client-to-server communication would be to have a Configuration object in the Workspace (so that it replicates), and have the server listen for children being added to it. Then clients can drop Value objects into it and the server will pick them up. You could expand it to let the server send a response by having the client wait for a child to be added to the sent Value object.
It's also simple to do the reverse the process for server-to-client. Just have all clients listening, and the server making requests. The only real difference is that you have to include which client the server wants to communicate with in the request, and only have clients that match respond.
You could even do client-to-client, if you wanted. |
|
|
| Report Abuse |
|
|
|
| 02 May 2012 08:09 PM |
@Anaminus
But that method is not really what I'd call "effective". It's not like there's any effective method to do it anyway. And there'd be no way for the devs to create an effective way to do it, because replication is more complicated than that.
You can't replicate functions, nor tables. The problem of tables, assuming you exclude threads (threads = the type of coroutines), functions and userdatas, can be solved with values, though. Or by converting them to strings. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 02 May 2012 08:20 PM |
So you have to do a drop/collect method in communications. You can use strings to save a copy of the table. I guess the real problem is transmitting the table back and forth again, and how you should handle updates efficiently.
This problem, it's quite annoying. |
|
|
| Report Abuse |
|
|
|
| 02 May 2012 08:23 PM |
| Why would you use strings for tables when you can use multiple values...? |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 02 May 2012 08:24 PM |
Efficiency. And the fact that the code exists for the table > string, and not for the values.
Unless you want to write it for meh. :) |
|
|
| Report Abuse |
|
|
Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 02 May 2012 09:27 PM |
I found the method to be pretty useful, considering the limitations.
You could use a bunch of values for tables, but you'd have to figure out how to verify that everything has been replicated before continuing. It's a lot easier to just wait on one string. Even so, you shouldn't have to send entire tables back and forth. It's a good thing to reduce network traffic as much as necessary. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 02 May 2012 10:27 PM |
I probably would only send over stuff I need. I think the best way to do this for a communal thing (Like a shop, or, say, a forum), which all players may be accessing is like this?
(-> means sending data/collecting data)
Local Script, parse -> Drop Point (.ChildAdded) -> Server Script `Handler` takes it, parse -> Drop off into new drop box -> Other local scripts (Other players) pick it up. (.Changed)
Is that the best method to do it? |
|
|
| Report Abuse |
|
|
DatBass
|
  |
| Joined: 30 Apr 2012 |
| Total Posts: 186 |
|
|
| 02 May 2012 11:25 PM |
A)) Yes script.Parent=nil --code
Magic & Tolerance |
|
|
| Report Abuse |
|
|
|
| 03 May 2012 05:37 AM |
https://code.google.com/p/google-diff-match-patch/
That should help you with updates, assuming that you're using strings for serialization. |
|
|
| Report Abuse |
|
|