|
| 07 Sep 2015 05:18 PM |
| What are the (dis)advantages of using _G to store player data like for example kills in _G rather than the traditional method of using value objects? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 07 Sep 2015 05:19 PM |
| the client won't be able to access the data |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 07 Sep 2015 05:20 PM |
| value objects were made exactly for this purpose |
|
|
| Report Abuse |
|
|
ByDefault
|
  |
| Joined: 25 Jul 2014 |
| Total Posts: 3197 |
|
| |
|
|
| 07 Sep 2015 05:22 PM |
@instawin
The client could still access the data via remotes no?
@ByDefault
How is that going to work? |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:23 PM |
| Use value objects, stop trying to do it this way, this is awful. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:25 PM |
@MaliciousMammoth
It seems to me that it's more memory efficient and much less of a hassle to work with when you have a lot of fields |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 07 Sep 2015 05:26 PM |
"The client could still access the data via remotes no?"
well yeah, sure, you could use a remote function to return the value inside of _G.. but why are you trying to dodge this? invoking to the server would just cause more network traffic than necessary. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:27 PM |
| They're more memory efficient? Lol, you shouldn't concern yourself with a couple kilobytes of saved memory. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:32 PM |
@instawin
It seems like a cleaner and easier to work with solution to me. I do not think it would increase network traffic by much at all since you could pipeline changing the data via a function that then fires a RemoteEvent for the client with the argument being the data entry changed and their new value. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 07 Sep 2015 05:35 PM |
do what you want, i just see it as more hassle though why go through all of that when value objects replicate to the client as well? you wouldn't even need to deal with remote events/remote functions |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:37 PM |
| It will take at least 100 milliseconds to get the value on faster connections, and up to a second on slower connections, but okay, do what you want. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:37 PM |
| But then every players data would be replicated to every other players client as well which would increase traffic significantly |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 07 Sep 2015 05:37 PM |
*you wouldn't even need to deal with remote events/remote functions (unless you want to invoke the server to change a value)
the client could access the value object and read from the value object's .Value property though |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:38 PM |
@foreverpower
What is your point? It is not like the value replication would be any faster in that scenario |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:38 PM |
| Well, when you want to get the value, do you request it, or does the server send the new value every time it updates? |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:42 PM |
| If you scroll up a bit you can see I have provided a solution to this particular issue which is using a RemoteEvent that fires upon the data |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:51 PM |
Using value objects are you best option. If you use remote events and functions, you lose the .Changed event (Very useful for displaying the stats instantly) and have to depend on latency. ie someone get's a kill, they don't get the stat update until anywhere from less than a second to sometimes 2-3 seconds or more.
There are no advantages to using _G over using value objects. Other than it 'feels nicer' grabbing data directly from a table, it's more common and logical to use Value objects.
As someone said prior, Value Objects exist almost solely for these reasons. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2015 05:54 PM |
Using _G over Value Objects
Advantages: 'Feels nicer' grabbing from a table
Disadvantages: No access to the .Changed event, you may need to keep looping to find out of a value has changed, or code a custom Changed event. Clients need to use remote events and functions to grab and detect data, this can be slow due to latency. |
|
|
| Report Abuse |
|
|