ID:272477
 
Hello,

How can i detect if someones key has guest in it ? before we just checked the name but since the new byond 4.0 gives the guest a name like Guest-123456789 its really annoying to detect.

Thanks
Look up the findtext() and findText() procs in the DM reference.
Sasuke_Kun52 wrote:
Hello,

How can i detect if someones key has guest in it ? before we just checked the name but since the new byond 4.0 gives the guest a name like Guest-123456789 its really annoying to detect.

All the BYOND 421+ guest keys are of the format "Guest-[number]", so you should be able to do this:

proc/IsGuestKey(key)
if(findText(key, "Guest-", 1, 1) != 1) return 0
var/i,ch,len=length(key)
for(i=7, i<=len, ++i)
ch = text2ascii(key, i)
if(ch < 48 || ch > 57) return 0
return 1


Lummox JR
In response to Lummox JR
Lummox JR wrote:
Sasuke_Kun52 wrote:
Hello,

How can i detect if someones key has guest in it ? before we just checked the name but since the new byond 4.0 gives the guest a name like Guest-123456789 its really annoying to detect.

All the BYOND 421+ guest keys are of the format "Guest-[number]", so you should be able to do this:

proc/IsGuestKey(key)
> if(findText(key, "Guest-", 1, 1) != 1) return 0
> var/i,ch,len=length(key)
> for(i=7, i<=len, ++i)
> ch = text2ascii(key, i)
> if(ch < 48 || ch > 57) return 0
> return 1

Lummox JR

.> that looks like a really good addition for a new DM update (nudge nudge developers, whomever they are)
In response to Sctjkc01
Sctjkc01 wrote:
that looks like a really good addition for a new DM update (nudge nudge developers, whomever they are)

That would be Lummox, although I don't think it needs to be added since it's easy enough to check for.

The only problem could be if someone actually created a key called Guest-[number]...
In response to Nickr5
OK, is there a way to check if he is actually a guest even if his key is say guest-453354435 ??? Because even checking key, their key could be that as well.

No kind of variable that is boolean for is-guest?

Also, how do you block all guests from your game besides checking the name? Is there a way?
In response to Superbike32
No, right now there's no other way (since guests are a new addition to BYOND). However, it's possible that BYOND won't allow you create a key in the Guest-name format. Even if they do allow it, I don't think anyone would be stupid enough to create a Guest key to play in a game where guests aren't allowed. It wouldn't kill them to create a new key if they did, though.
In response to Nickr5
'Guest' is a reserved word, so you can't make a key with it. The BYOND Staff knows their stuff. (rhyme intended) :P
In response to Kaioken
Well, still, I would feel much better having a variable containing whether or not its a guest key. It would save me some copying and pasting, and it would be a built in function, so that we cant really mess up if we know what variable it is, and know how a boolean variable saves the data...hahaha
In response to Superbike32
That'd be a waste of a built-in variable. =P You've got Lummox JR's code right here, you can copy it once and you can use the proc all you like, or set your own custom variable when a player logs in. Since you can already easily detect it because a player can't actually create a key in the Guest-#num format, this is enough and you don't really need a built-in variable.

If anything, you'd have that proc built-in, which would be nice and similar to how you've got IsBYONDMember().