|
| 21 Aug 2014 10:10 PM |
| Is using remote functions to access data stores and save player data efficient? Like, if the server were to be invoked by two people at the same time, would it glitch? |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Aug 2014 10:39 PM |
| I don't see any reason to use a remote function to access data stores. But no, it shouldn't have a problem. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 10:45 PM |
@vector The point of RemoteFunctions/Events is to communicate between the server and client |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 10:55 PM |
| Apparently you can't read. I didn't say I didn't know what remote functions did. I just didn't see a purpose to use for datastores. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 11:50 PM |
dang son tone down the sass i aint mean no disrespect
Seriously though I meant that if you needed to access a data store through the client you'd need a RemoteFunction to do it for you because GetDataStore only works server-side |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Aug 2014 01:48 AM |
You can do that or you could create a metatable on the server's global table and access that from the client. This way, the actual sensitive data never becomes client-controlled, so you can prevent CE exploiting. |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2014 02:06 AM |
To access it, we could try something like this:
SERVERSIDE
metadata = { __call = function(table, ...) local args = {...}; local ds = game:GetService("DataStoreService"):GetDataStore("gdata"..args[1].userId); return ds:GetAsync(args[2]); end };
local md = setmetatable(_G, metadata);
LOCAL ACCESS local coinval = _G(game.Players.LocalPlayer, "Coins"); |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Aug 2014 03:31 PM |
| I thought _G on the server and _G on the client were two separate environments, no? |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2014 03:53 PM |
@nice; In normal lua, yes, but in RBX.lua, I believe the environment is shared.
this is a signature: pcall(function() print([[apparently this is a string]]) end) |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2014 09:01 PM |
| @kot, they're actually separate in server and client, which is why they made remote objects, I believe. |
|
|
| Report Abuse |
|
|