Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Tilar
Newbie


Joined: 03 Feb 2002
Posts: 9

PostPosted: Thu Jul 25, 2002 7:02 am   

A possibly impossible alt finder
 
I'm an immortal at a MUD called Time of Darkness. On this MUD, when someone logs on, I see this:

--> Billybob@xx.xxx.xx.xx has connected.

With the x's being the person's IP address. I set up a trigger to store the IP address of the person in a variable of the person's name, like so:

--> %1@%2 has connected.
#var %1 %2

I then set up a trigger for it to display that person's IP address when they logged off, since I normally see this:

--> Billybob rejoins the real world.

Here's the trigger:

--> %1 rejoins the real world.
#sa %1's IP was @%1

What I would like to do is take this one step further, if at all possible, by having a trigger or some sort of function that will check through all of my variables and recognize ones with matching IP numbers. I'd ultimately like to be able to use it to give me a list of a person's alternate characters whenever they log off or on. Is this at all possible? Any help is appreciated.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jul 25, 2002 10:59 am   
 
I would suggest you change your storage structure. A db structure you provide the most effecient means to do what you want. Next best would be to use 2 lists. I could walk you through the list, but if you want the db someone else will have to answer that. For some odd reason I refuse to learn the functions and commands for it.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jul 25, 2002 12:16 pm   
 
First, you don't use %1..%n in the pattern of your triggers, you use a wildcard and you surround it in parenthesis to have it saved to %1, %2, etc. So, for example, you first pattern would be:
(%w)~@(%x) has connected.

Next, like Vijilante suggested, you can do this in a more efficient manner by using a record variable. For this, you usae the #ADDKEY command like this:
#ADDKEY characters "%1" "%2"

This will add a key-value pair to the characters variable. In this case, the key is the character's name and the value is the IP address. By using this method, you end up with just one variable that contains all of the names of the characters and their respective IP addresses. You can avoid duplicates in this list, by changing the above to this:
#IF (!%iskey(@characters, %1)) {#ADDKEY characters "%1" "%2"}

If you want to check the value of one of the keys in the variable, you use the %db function. Lets use your second trigger as an example:
#TRIGGER {(%w) rejoins the real world.} {#SAY %1's IP was %db(@characters, %1)}

Finally, in the first trigger, you can check to see if that IP already exists by doing this:
#LOOPDB @characters {#IF ((%key <> %1) and (%val = %2)) {#SAY %1 is a multi of %key}}

Kjata
Reply with quote
Tilar
Newbie


Joined: 03 Feb 2002
Posts: 9

PostPosted: Thu Jul 25, 2002 11:35 pm   
 
Ok, so far, it is storing everything in a single variable named "characters". When a person logs off though, it just says "Name's IP was" with nothing but a blank. Seems to me like it's having troubles getting the data back out of the database. I've looked over it, but don't really know enough about databases to understand what's wrong. Also, the part where it is supposed to name one's alt's doesn't show up at all. Is there anymore help you can give? At least, help me get it to where it will show the IP's again using this new, better variable?
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Fri Jul 26, 2002 12:13 am   
 
I too would recommend a db variable to track this. However, I would use the IP address as the key and put a string list of corresponding character names as the value.

#TR {--~> (%w)~@(%x) has connected.} {
#VAR temp %db(@characters, %2)
#ADDITEM temp %1
#ADDKEY characters %2 @temp
#SAY Characters using this IP are %expandlist(@temp, ", ")~.
}

#TR {--~> (%w) rejoins the real world.} {
#LOOPDB @characters {#IF %ismember(%1,%val) {#SAY Possible alts of %1 include %expandlist(%val, ", ")~.}}
}



Troubadour
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Jul 26, 2002 12:21 am   
 
It works fine for me (except the reporting of multis which should now work), and I have this:
#TRIGGER {(%w)~@(%x) has connected.} {#LOOPDB @characters {#IF ((%key <> "%1") and (%val = "%2")) {#SAY %1 is a multi of %key}};#ADDKEY characters "%1" "%2"}
#TRIGGER {(%w) rejoins the real world.} {#SAY %1's IP was %db(@characters, %1)}

I removed the check to see if a key already exists before adding it because I forgot that record variables do not add duplicate, they update the value of the existing key. I did this because most people have dynamic IP addresses that change from time to time.

Kjata
Reply with quote
Tilar
Newbie


Joined: 03 Feb 2002
Posts: 9

PostPosted: Fri Jul 26, 2002 6:36 am   
 
I hate to continue this on, but I'm still having problems getting it working. It seems to me like the trigger is having a problem finding and returning the key, so that it always sends a blank. Even when I'm just sending tells to myself trying to get something out of the variable characters, I get a response of nothing. Here's what it says is happening, maybe it will help:

--> Srixon@63.190.81.129 has connected.
[(%w)~@(%x) has connected.-> #LOOPDB @characters {#IF ((%key <> "Srixon") and (%val = "63.190.81.129")) {#SAY Srixon is a multi of %key}};#ADDKEY characters "Srixon" "63.190.81.129"]

--> Carbuccle rejoins the real world.
[(%w) rejoins the real world.-> #SAY Carbuccle's IP was %db(@characters,Carbuccle)]
Carbuccle's IP was

On both of these characters their IP was definately already in my variable, so I don't understand the problem. Maybe I don't know what I'm talking about, but does the %db command work for variables? I don't have the variable made into a database. Do my settings matter? I have everything turned on right now but Show Triggers, Echo Commands, Echo Messages, and Strip " quotes. I had to turn on Expand Vars...which helped a little, but still not the result we want. Also, does the variable have to be a data record or does it need to be a vbscript or jscript or string list or something similar? Thanks for any last help you can give :)
Reply with quote
Tilar
Newbie


Joined: 03 Feb 2002
Posts: 9

PostPosted: Fri Jul 26, 2002 7:03 am   
 
Ok, forget all that! Apparently it was that strip quotes deal that needed to be on, so I went through and deleted all quotes in the database, and now it doesn't save them anymore. I *believe* it is working now, and I thank you both for all the help! If nothing else, I've learned a bunch about database records now.

Thanks again.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net