ID:160264
 
Can anyone help me out with a code to prevent guests from signing on my game?
There are a couple of ways to do this, I believe the best way to do it is when the client first logs in. So we're going to have to do this in client/New().

Now, logically thinking, guest keys aren't just "guest" anymore, so we can do an if(src.ckey == "guest"). If I recall correctly, guest now has a series of alphanumerics after it. But still contains the word "guest".

With that in mind, we're going to have to look at the findtext() proc.

client
New() //When a client first logs in.
if(findtext(src.ckey, "guest")) //If we find the text "guest" in the clients ckey.
src << "I'm sorry, but this server does not allow guest keys." //Inform them we don't accept guests.
del(src) //Sever their connection.
..()


This is a very simple question, so I supplied you with a working snippet. But please, read the reference to the functions I mentioned. It'll help you later down the road when you wish to do more complex things.
In response to Tiberath
ok thanks im doing that now
In response to Christopher52488
You might also want to make sure that it's in the beginning of the name, so "SuanaGuest999" doesn't get banned.
In response to Jeff8500
ok............
In response to Jeff8500
Jeff8500 wrote:
You might also want to make sure that it's in the beginning of the name, so "SuanaGuest999" doesn't get banned.

Oh hey! Good point! That completely slipped my mind.

To do that, you'll want to pay a visit to the DM reference and look up copytext()
In response to Tiberath
_> Nah, you could still use findtext().
if(findText(key,"Guest-")==1) //if it was found at the beginning (first char position)
src << "you're a guest!"


Or, if you want it to be perfect in the detection: [link]

Also, you could manage this kind of checking in world/IsBanned(), before a client is even created.
In response to Kaioken
Good find on that IsGuest() proc. But I think the concept of it might be overstepping a beginner-programmers understanding ability. (But you're right, it's pretty perfect.)

And huh, I never really considered findText(). I very rarely, if at all use it, so it falls under the category of "I seem to recall a proc doing this..."