ID:179498
 
I want to make it so that when a player logs in, if there are no other clients in the game, it automatically hosts the world. Here's what I thought:

world
mob = /mob/joined
mob
joined
Login()
if(!clients)
client.mob = new/mob/DM()
world.address = client.address
else
client.mob = new/mob/player
..()
Evilkevkev wrote:
I want to make it so that when a player logs in, if there are no other clients in the game, it automatically hosts the world. Here's what I thought:

world
> mob = /mob/joined
> mob
> joined
> Login()
> if(!clients)
> client.mob = new/mob/DM()
> world.address = client.address
> else
> client.mob = new/mob/player
> ..()


Well, client.address is always null for the host, but I don't see a question around here anywhere. ;-)
In response to Spuzzum
Here's the question: How would I force the first person to enter the game, to host it? :)
In response to Evilkevkev
Use a little undocumented call: world.OpenPort(). You might want to do something like this:

mob/Login()
. = ..()
if (!world.port)
world.OpenPort()

Or you could do it once in world/New() if you like.