So how do we go about this? The best time to check is before the person join the server - when DM checks if the person entering is banned via the host's pagerban - which is at world/IsBanned().
The best part of this is that if the person is not logged in, they cannot download any resources from the server.
// Guest Denial Snippet
// Made by GhostAnime
// August 4, 2014
world
IsBanned(key,address,computer_id) // This is called before the person is logged in to the server. It will help save resources from being downloaded if the person is banned as they will be disconnected before the rsc d/l starts
. = ..() // Check if the person is already banned
if(findtext(key, "Guest-", 1, 7)) // If a Guest logs in [NOTE: Does not affect the host. If you want the host to be with a key... well, I'll show you shortly
.["Login"] = 0 // Deny the person from logging in
.["message"] = "Please log in to play [world.name]" // A message displayed to the Guest informing why they cannot login.
// There is also .["reason"] which is the reason why the person was pager banned. Not needed here though
Edit: As Pirion mentioned, the message may not be received by the user explaining why they were unable to log in due to the splash screen.
As an alternative for this case, move the check under client/New()
-------------------------
As you may have read above, the host is the exception.
So what do you do if you want to make sure that the host is logged in? You have at least three choices:
(1): Verify if the host/player is logged in at client/Login()
or
(2) Deny the host from hosting the game:
world
OpenPort(Port=0) // This is called when the host of the game is attempting to host.
if(!world.host || findtext(world.host, "Guest-", 1, 7)) // If you REALLY want the host to be logged in for hosting,,,
world.log << "Please log in to host this game!"
return 0 // Deny the game from being hosted
.=..() // Allow the game to be hosted if the world.host is set to a non-Guest key
world.log << "The game is \..." // \... surpresses a newline
if(.) // If the hosting was successful. I could have the compact-if() statement [X?Y:Z] here as well. which is like saying if(X){return Y}else{return Z}
world.log << "now hosted on port [.]!"
else // The game did not open the port for whatever reason
world.log << "NOT hosted.\nFailed to open Port [.]"
(3) Alternatively, you could do the world.host check at world/New() and shutdown/delete the world if the host is not logged in.
world
New(Port=0) // This is called when the game starts.
if(!world.host || findtext(world.host, "Guest-", 1, 7)) // If you REALLY want the host to be logged in for hosting,,,
world.log << "PLEASE LOG IN TO PLAY THIS GAME!"
shutdown()
return ..() // In case you have any world/New() instances