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
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Feb 01, 2007 10:20 pm   

Database questions...
 
Though I've been scripting for zMUD for a while, I never touched on databases. They were something that I didn't have a need for... until now.

I'm actually assisting a friend in creating a recruiting script for his clan. He's made the script, but there's one flaw - it'll only store the most recent variable. Not helpful when we want to have the variable stored for all names in the list. So, the only way I can think of is using a database to store the name, then the many variables for each name. But for starters, I need to know what commands I need to put in to start a simple database as follows:

Name: Alfred
Name: Brian
Name: Charlie
etc...

Then, I need to loop that database for all names, giving each one a specific command (i.e. whois <name>), then store the different variables for each list. For instance..

whois alfred
Alfred: Level 20 Elf Cleric

So I'd need it to variable the level to Alfred's name in the database and so forth. Is this even possible? And did I make myself clear enough on this? Thanks!

Charneus
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Feb 02, 2007 2:29 am   
 
It's difficult to explain how to set up a DB since it's mostly just follow-the-GUI.

Open the DB window, File > New (if it doesn't already prompt you to create a DB), call your DB something ("Players" for this example), and you should be in the Fields view (that is, the left hand part will have a blank area and above that blank area will be a title "Fields". Use the Add button to add fields, you should need:

Name (text)
Level (number)
Race (single option, add the races your game has into the option names)
Class (single option, unless you can multi class, then pick option list, and similarly add the available classes in)

Make sure you use the "Save" button after you add the last field.

Now a script... You'll want something like:

#TRIGGER {whois (*)} {}
#COND {(%w): Level (%d) (%w) (%w)} {#var player %null;#addkey player {Name=%t1|Level=%1|Race=%2|Class=%3};#new Players @Player}

With the first one set to Input and the second one set to Within Lines (I would say within 3 or 5, depending on how laggy your connection is is).

And then once you've worked out all of my typos and stuff, you can just use whois (one at a time) on everyone you want to add and it should all go into the DB--remember that the DB has to be -open- for ZMud to add to and read from it!

Also make sure to look through the DB section in the help (for some reason this is part of the "getting started" section--I've never figured that one out) but it's particularly useful.
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