[Metis] Saving to Files

Discuss all kinds of software here including apps, games and operating systems. You can also share software guides and receive help for your software in this section.
User avatar
Pri
Site Admin
Site Admin
Posts: 5433
Joined: Fri Dec 14, 2007 8:59 am

[Metis] Saving to Files

Thu Jan 10, 2008 12:09 am

Today I'd like to show how to save information to files!

Many Bots need to remember information between reboots. One of these (Which is quite important to most rooms) Is a basic logging system.

Being able to record the users who enter your room is practically step 1 in keeping your room safe. When people come in to the room pretending to be someone who they are not you can simply open the log and see if the information matches the person they say they are.

So lets get started. First of all lets have a breakdown of what needs to happen.

A user enters your room, The bot detects that a new user entered the room collects information about that user and then deposits it to the end of your log (Not overwriting what is already there).

Pretty simple stuff.

So how does the bot detect when a new user enters the room? - With the following tags.

Code: Select all

<OnEnter type="script">
</OnEnter>
The code above means when the bot sees any user enter the room it executes that script. So lets fill it up!

Code: Select all

<OnEnter type="script">
<out type="file" mode="a" extdata="C:\log\Entry.Log.txt"> \n NAME: %NAME% \n IP: %IP% \n HOSTNAME: %HOSTNAME% \n CONNECTION: %LINE% \n FILES: %FILES% \n TIME: %LOCALTIME% \n DATE: %DATE% \n ROOM: %ROOMNAME% \n </out>
</OnEnter>
Now I know it looks complicated! So lets explain some of what is displayed above. First we see this:

Code: Select all

<out type="file" mode="a" extdata="C:\log\Entry.Log.txt">
1. The first part says out type="file" which means you are selecting the way it will be outputting the data you want it to output. In this case we want it to output the data to a file.

2. The next part says Mode="a" This is important there are 2 letters you can use here t and a. t means it will overwrite the file it finds. Basically it will delete the file and make a new file with new information in it. We don't want it to do that as this is a log. So we use a which means it accesses the file and adds more information to the end of it.

3. The next part says extdata="C:\log\Entry.Log.txt" this is basically you telling the bot in which file it should be saving the information. In this case we chose the C drive and a folder called log and then the file it creates will be called Entry.Log.txt - It is important that you create the log folder in C before running the script or it will not know where to save the log file. You can use any directory you want on your PC to save information.

4. The final part of the script says: \n NAME: %NAME% \n IP: %IP% \n HOSTNAME: %HOSTNAME% \n CONNECTION: %LINE% \n FILES: %FILES% \n TIME: %LOCALTIME% \n DATE: %DATE% \n ROOM: %ROOMNAME% \n So lets explain this. \n means New Line. So after each bit of information it will create a new line in the text file (So that information is easy to read and not cluttered together). Some of the information that will be collected, The users Name, There Hostname (basically there Internet Service Provider information) the Date that they entered the Time that they entered and the Room that they entered. (The room may be important because it includes all the numbers at the end of the Name and if you have Multiple hosters it will make it easier to identify who was hosting at that time).

So lets say you've run the script and someone has entered lets open the Log and see how it looks!. This will be your first Entry:

NAME: Dave
IP: 123.45.67.89
HOSTNAME: mar-123-45-67-89.host.someone.com
CONNECTION: Cable
FILES: 1572
TIME: 23:44.47
DATE: 09/01/2008
ROOM: My Fantastic Room_291KD0FA0

As you can see it wrote all the information down in a clear and legible manner.

And remember you can save almost anything in to a text file including user variables (Which we showed how to make in our first guide).

Return to “Software Centre”

Who is online

Users browsing this forum: No registered users and 10 guests