|
| 18 Sep 2014 11:44 AM |
Is it possible to save data when the server is shutdown? I started using a new method to update my values when the player leaves instead of using the .changed function. The .changed function works when the server shuts down, but no need to use that. If I use playerremoving, how could the values save on shutdown? I used this:
Game.OnClose = function() wait(3) end
That did not work. Sorry for re-posting, no one last night new what to do. |
|
|
| Report Abuse |
|
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Sep 2014 12:05 PM |
Nobody. I don't know, really. Just make sure you consistantly store the values you need to save on game shutdown and then update them on the datastore when OnClose is called. Also game ~= Game |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
| |
|
|
| 18 Sep 2014 12:07 PM |
| I already tried storing the values on shut down. Did not work. How would nobody not know what to do...? Unless all the helpers are at school... |
|
|
| Report Abuse |
|
|
Tynezz
|
  |
| Joined: 28 Apr 2014 |
| Total Posts: 4945 |
|
|
| 18 Sep 2014 12:11 PM |
| I'm 11 so really. I have no clue. |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 18 Sep 2014 12:15 PM |
game.OnClose:connect(function() end)
you weren't running it through the event handler |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2014 12:19 PM |
| Wait what? Does it matter where the code is placed? I'm sorry i'm a little confused. |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 18 Sep 2014 12:20 PM |
just like how a brick uses
script.Parent.Touched:connect(function() end)
you need to connect the OnClose event the same way |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Sep 2014 12:32 PM |
Game.OnClose:connect(function() wait(3) end)
Error: OnClose is a callback member of DataModel; you can only set the callback, get is not abailable? |
|
|
| Report Abuse |
|
|
Bobobob12
|
  |
| Joined: 23 Jan 2008 |
| Total Posts: 5350 |
|
|
| 18 Sep 2014 12:37 PM |
oh nevermind, you did implement it right since OnClose is just the callback
so the last player's stats aren't saving? |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2014 12:40 PM |
| Yeah. I've been trying everything to see what I can do. I even tried a loop to save every 15 seconds but that would really be needed. The data saves when a player leaves. But if the server is getting forced to shutdown it does not count the player leaving. I was trying to use OnClose to maybe secure that problem but it seems to not be working well... |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 18 Sep 2014 01:09 PM |
I'm not sure OnClose even locally fires. -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 18 Sep 2014 01:12 PM |
| Whats the point of the wiki saying it should secure the data before shutdown then? Is their any other way to secure my data on shutdown? |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 18 Sep 2014 02:36 PM |
OnClose() does not secure your data. You need to do that yourself. OnClose() just runs something for up to 30 seconds before the server is allowed to shut down. You need to put all your code to save everything important in there. Also has to be on a server script in case you were being super silly |
|
|
| Report Abuse |
|
|