How can create a list of keys that I want to allow to Login?
EX:
mob/Login()
if(!src.key=="Xallius")
del(src)
How can I implement this for multiple keys?
EX: I want to allow keys: "Xallius" and "Azen"
I know this is relatively simple and I thought that I would just use the || operator, but I can't seem to get that to work.
Thanks.
ID:147503
Apr 19 2004, 3:01 pm
|
|
In response to HavenMaster
|
|
Ok, I figured it out, thanks.
The coding you sent just needed the || replaced with &&. with && "If the key is not Xallius or Azen, delete them" opposed to: with || "If the key is not both Xallius and Azen, delete them" |
In response to Xallius
|
|
An even easier way would be
if(!(key in list("Xallius","K1","K2","K3")) |
In response to Xallius
|
|
Actually
|| = OR && = AND |
In response to Nadrew
|
|
But in this instance.......
mob/Login() if(src.key!="Xallius"&&src.key!="Azen") del(src) The && will allow a key if it is either Xallius or Azen, where as.... mob/Login() if(src.key!="Xallius"||src.key!="Azen") del(src) This would only allow a key that was both Xallius and Azen.. Impossible =) You have to think of what it would do logically instead of the definition of the operators. |
In response to sapphiremagus
|
|
Thanks. That should save me some typing. =)
|
In response to Xallius
|
|
Right-o.
if(foo != bar && foo2 != bar2) is equivalent to if(!(foo == bar || foo == bar2)) What you want is a foo that is neither bar nor bar2, so or makes sense, but you distributed the not across the equation so it switches the or to an and. |
In response to XzDoG
|
|
This really isn't the best way to solve this problem. Any time you want to change the list, you have to recompile the game and restart it. If you're seeding copies to trusted testers/hosts, you have to make sure they all update their copies. It can easily turn into a logistical nightmare.
Instead, simply create a hub entry with distribution by invitation only. Go to the subscribers list and add/delete anyone you want, any time you want. In your code, do something like this: client/New() You'll never have to update this piece of code again. |
mob/Login()
if(src.key!="Xallius")
del(src)
Or, for multiple keys:
mob/Login()
if(src.key!="Xallius"||src.key!="Azen")
del(src)