MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 09 Dec 2014 11:45 PM |
| So... This is going to be a complicated question... I really want to learn something here though... The gist of what I'm trying to do is in a game have a poll system that basically stores all responses in my PlayerData. I'm envisioning the following. NoobABC123 enters poll game. In MattJon's PlayerData for this game, there is a saved table- called... responses. So... load the table up (also, possible to load data of player not in server?) and then based on how NoobABC123 responds to the poll, it creates a new table, and this table is actually saved as a value in the responses table. So... say NoobABC123 picks choice A or something, then responsenumber = 5 (let's say he's the fifth person to "respond") and NoobABC123 = {response1 = A, response2 = B, response3 = A}. then finally does a table.insert and now NoobABC123 (the table) is saved in MattJon's PlayerData, responses. Like so... responses[5] (The responsenumber) = NoobABC123. So then when I join, I could have a script compile everything from responses[1] to #responses and count stuff up for me. Anyway to make this work? Theoretically, is what I'm trying to explain possible/plausible? Are there any flaws in my reasoning or knowledge? A more efficient way of doing this (I want this done IN a game)? |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 09 Dec 2014 11:50 PM |
| You should use data stores for this. I did something like this when I made a world leaderboard. |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 09 Dec 2014 11:51 PM |
| If you don't know how to script I will make you one if you want! Just message me. |
|
|
| Report Abuse |
|
|
ash877
|
  |
| Joined: 18 Feb 2008 |
| Total Posts: 5142 |
|
|
| 10 Dec 2014 12:29 AM |
I haz bettar leaderboard C:<
-Ya, use data stores so a player's data can be retrieved regardless if they're somewhere else. |
|
|
| Report Abuse |
|
|
MattJon
|
  |
| Joined: 28 Apr 2009 |
| Total Posts: 660 |
|
|
| 10 Dec 2014 12:41 AM |
OK... So say the poll is a question and you can choose a, b, or c. a = 1, b = 2, c = 3. noobers156 chose A. noobers156's userId is 10003943...
local DataStore = game:GetService("DataStoreService"):GetDataStore("Responses") -- function-y stuff, idk, I'll probably have a GUI button... local key = "user_" .. player.userId -- player will be previously defined. DataStore:UpdateAsync(key, function(oldValue) local newValue = 0 --oldValue might be nil newValue = 1 return newValue end) end)
------------------------------------------- That's my roughly edited version of a DataStore script from the wiki. I mostly understand what is going on, but then I don't know how to access and use that data. First, can "newValue" be a string? Can DataStores do strings so A doesn't have to equal 1, it can just be newValue = "A"? Second, how do I access all this!? How do I compile all the players' datas from the "Responses" DataStore and count the A's, B's, and C's? |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 10 Dec 2014 12:43 AM |
| Are you going to message me back? |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 10 Dec 2014 12:44 AM |
| I'm really good at data stores. I made a working world leaderboard. |
|
|
| Report Abuse |
|
|