ID:154033
 
How would I implement a code so that only certain people can join.... I've never been able to do it :/
Macros wrote:
How would I implement a code so that only certain people can join.... I've never been able to do it :/

Here, use this:

var/list/BetaTesters = list("Mellifluous","Dan","Tom") // Just add a comma (",") at the end of each quoted name/Key to allow another person to enter.


This list determines the Key's of the people who are able to join a Closed Beta test.

This gets looked at from the coding done below.

mob/BaseCamp/ChoosingCharacter/Login()
if(BetaTesters.Find(usr.key))
spawn(1) src << "Welcome to [world.name]; you are an approved tester."
..()
else
src << alert("Sorry, but this is currently a closed Beta. Please check back in the future!")
var/mob/M = src
var/key = src.key
src = null
spawn(1)
world << "[key] tried to join but was denied access."
del(M)


This checks the players "Key" upon the Login() process of the game. If the players Key is located in the Beta's List as shown at the very beginning then the player is granted access into the game, else, if the players Key is not located in the Beta's List then the player is not granted access to the game, therefore booting him/her from the game with an alert/pop-up message.

--Lee
Mellifluous' recommendation is good. If you aren't using CharacterHandling, GateGuardian made a useful snippet:

//Credit to: GateGuardian

//This piece of code allows only certain people to log in,
// booting all others. Just fill in the list of Members
// with the keys of the people who are allowed to join,
// and it'll do the rest.
//If it doesn't work, it's probably because you neglected
// to call "..()" inside your Login() proc.


var/list/Members = list("Alpha","Omega","Whoever")

mob/Login()
..()
spawn() MemberCheck()

mob/proc/MemberCheck()
if(Members.Find(src.key))
return
else
src << "Beat it, loser!"
del(src)