| |
|
|
| 27 Feb 2015 12:25 PM |
Do you mean game.OnClose? game.OnClose is a callback, so just use it as you would any other callback. (Another callback example is RemoteFunction.On(Client|Server)Invoke) |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:25 PM |
http://wiki.roblox.com/index.php?title=API:Class/ServiceProvider/Close
I thought you could like force shutdown a game. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 12:29 PM |
That's an event, so you can't fire it manually. Read the description for it.
Also, I'm pretty sure it would be locked if it was a method. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:42 PM |
local game = setmetatable({ Close = function(t) for i,v in pairs(game.Players:GetPlayers()) do v:Kick() end game.Players.PlayerAdded:connect(function(p) p:Kick() end) end }, { __index = game, __newindex = function() error("Attempt to add index to game", 2) end, __metatable = "Attempt to modify protected metatable" })
game:Close() |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:43 PM |
local game = setmetatable({ Close = function(t) for i,v in pairs(Game.Players:GetPlayers()) do v:Kick() end Game.Players.PlayerAdded:connect(function(p) p:Kick() end) end }, { __index = Game, __newindex = function() error("Attempt to add index to game", 2) end, __metatable = "Attempt to modify protected metatable" })
game:Close()
--Fixed slight issue, not sure if it mattered though. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:51 PM |
english please?
i don't even know what a metatable is explain pls |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 01:57 PM |
| Just add my code it, it can shut down a game with game:Close() |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 02:37 PM |
| For the record, I am HIGHLY opposed to that, warspyking. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 03:19 PM |
| I know it works, but I wanna know what everything means. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 03:31 PM |
game.OnClose == function() -- Write code here that you want to execute before the server shuts down end |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 03:35 PM |
He means game.Close, not game.OnClose. And you don't assign it like that, Augmentary. :(
Abstract, you will need to learn about metatables and the function environment from the wiki, I don't feel like teaching it.
Also, I find it offensive how you are in RbxDev and I am not. I don't mean to say you are inferior though, that would be dumb. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Feb 2015 03:36 PM |
| "==" means it returns either true or false, since it is a comparison operator. And no, assigning it like that does NOT work for you, because that does not assign it. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Feb 2015 03:40 PM |
http://wiki.roblox.com/index.php?title=Sandboxing#Function_enviroments http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#setfenv http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#getfenv http://wiki.roblox.com/index.php?title=Metatable |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 Feb 2015 03:43 PM |
| (Psst, War. Your way breaks methods) |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 05:45 PM |
(psst eLunate, it still works XD)
@Jarod Don't be highly opposed, he simply asked for game:Close()
Was it wrong of me to give it to him? |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 05:46 PM |
| I'm just opposed to wrappers that don't meet my standards. eLunate's is the closest, but not good enough. |
|
|
| Report Abuse |
|
|
GOLDC3PO
|
  |
| Joined: 31 May 2011 |
| Total Posts: 509 |
|
|
| 27 Feb 2015 05:48 PM |
game.OnClose:connect(function() Quicklysaveallthegamesdata() wait(30) end) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 27 Feb 2015 05:50 PM |
| (Psst, your way does definitely break methods like :FindFirstChild on game because it calls Instance.FindFirstChild with a table as the first argument) |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 05:55 PM |
| (Psst, still don't care, not trying to make a seemless wrapper, just trying to make game:Close()) |
|
|
| Report Abuse |
|
|
| |
|
mew903
|
  |
| Joined: 03 Aug 2008 |
| Total Posts: 22071 |
|
|
| 27 Feb 2015 08:27 PM |
ITT: warspyking being stupid again and other people confusing events for callbacks/methods
@OP The thing you're thinking of is an event that fires when a server is about to close. I'm not sure if it's locked or not and I don't think there's an easy way to find out. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2015 08:54 PM |
| @above What do you mean again? Also there is an easy way to find out, set it up to save to a DataStore, then leave so it can shut down, join again, and use cmd line to see if it saved to the DataStore |
|
|
| Report Abuse |
|
|