generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: game.Close ?

Previous Thread :: Next Thread 
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 12:19 PM
How to use?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 01:51 PM
english please?

i don't even know what a metatable is explain pls
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Feb 2015 01:57 PM
Just add my code it, it can shut down a game with game:Close()
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Feb 2015 02:37 PM
For the record, I am HIGHLY opposed to that, warspyking.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 03:19 PM
I know it works, but I wanna know what everything means.
Report Abuse
Augmentary is not online. Augmentary
Joined: 30 Aug 2013
Total Posts: 8081
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
Augmentary is not online. Augmentary
Joined: 30 Aug 2013
Total Posts: 8081
27 Feb 2015 03:35 PM
@Jarod:

works for me
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
27 Feb 2015 03:37 PM
@Jarod

link?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
27 Feb 2015 03:43 PM
(Psst, War. Your way breaks methods)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Augmentary is not online. Augmentary
Joined: 30 Aug 2013
Total Posts: 8081
27 Feb 2015 08:23 PM
@Jarod:

TYPO LEL
Report Abuse
mew903 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image