ID:153702
 
Ok I'm trying to cover all my corners here. I already have some code.. But just to make sure.. I DON'T want to make my program hostable as it's intended for single, local client use ONLY!! So I wish to disable hosting of the program, also do not want to let others join a game in progress, and make sure it's viewable for download, but does not show up on any hubs.

Would like to see some code to prevent this sort of thing, ,as I'm unsure of all the ways into a game, and just want to make sure my bases are covered.

Thanks..
LJR
You can't, at least not in this version of BYOND. The only alternatives are to have a repreating proc continually setting the world to invisible, and to boot anyone who logs into the game if there is already a player.
In response to Foomer
Well thats very surprising.. can someone from Dantom tell me its not so??!! :O

Hmmm if stand alone program are to be developed for this platform, we MUST have support to disable that option.
In response to LordJR
This platform is designed for multiplayer, not standalone. But BYOND 4.0 should have an option to disable hosting.
In response to Foomer
Use something like this to keep people from coming in:

client/New()
if (!address || address!=world.address || address!="127.0.0.1")
src <<"Sorry, this is a single player only game"
del src
..()


And you can always just stick in world.status something like "Single-Player Only: No spectators allowed" (Plus a little publicity from being listed as live wouldnt hurt)

And writing the little thing on hub publicity, you could also probably create a hidden hub entry and set the world.hub to the hidden entry (should make it not show up live) and use the real one as you usually would.

[EDIT]
Making a hidden hub entry for it would work, it would however still allow people to join via pager, so a combination of the client/Login() code and the hidden entry would work fairly well.
{/EDIT]
You can call world.OpenPort("none") to force the world to not accept any new connections (note that it can be opened back up by the user or another call to OpenPort()). You'd have to do this on a timer loop, or just every time someone tries to log in.
In response to LordJR
Go and download Nadrews Useful Functions from BYONDscape.com

One of the functions disables hosting
In response to LordJR
::is from Dantom..sorta::

What you need to do is use the world.OpenPort() proc in a loop like so:

proc
nohost()
set background = 1
spawn(10) while(1)
if(world.port) //if it's hosted
world.OpenPort("none") //un-host it.



And, all you need to do is call the proc once.
In response to Nadrew
I'd do it more like this:

<code>proc nohost() if(world.port) //if it's hosted world.OpenPort("none") //un-host it. spawn(10) .()</code>

Wouldn't that be faster? As it's only checking once every second, and using spawn() rather than a background proc.
In response to Nick231
I've got another idea... The host plays the game, other people spectate. I guess it's analogous to playing a game in an arcade or one of those console demos that they have in electronics stores. You just need to set up something like
client.eye = host
.
In response to Cybermattr
Cybermattr wrote:
I've got another idea... The host plays the game, other people spectate. I guess it's analogous to playing a game in an arcade or one of those console demos that they have in electronics stores. You just need to set up something like
client.eye = host
.

That's what I did for my entry in the solo adventure contest. The first mob to Login() became the player, and all they can host if they want, but all other players that joined would just be watching them.