- Aug 4, 2003
- 256
- 7
- 114
so i seen alot of people have incorporated SQL scripting onto their servers, which is great.
However, sometimes it is easier to use a more simple method. I noticed there was no posted tutorial on this
so I figured I would make one, it might help some of you make more simple scripts that allow things to be saved
without resorting to make a table in SQL.
First off, what can a .txt file store? It can basically store 2 unique columns of data, they can be numbers
or words. You can add, subtract, update, edit, load things from text files. Unfortunately with that limitation
you can't store 3+ columns of data in a text file (to my knowledge, correct me if i am wrong ) However, you can
seperate columns out, so in retrospect you can actually store alot more data then you think.. I'll explain below
Lets start off with some terms to no, i think you no probably in general what these things do. so lets start off
with an example on how to use them.
SaveValue
Loadvalue
addnamelist
checknamelist
!CheckNameList
now lets start a script in 00default.txt that check's if its a new player or not, and then gives the user a custom welcome message
If this is done properly, you can go into newplayermessage.txt
and you should see something like this...
Now as I mentioned earlier, you can indeed save multiple categories in the same text file, I won't draw out another example for it
but say we want to add another category that saves numbers. Unlike SQL we would have to go back and make a new table. Not with .txt files
Mir3 should simply add in the category for you.
Say I want to store a certain number along with their username in the same text file to save space. I could do something like..
and when we want to call up data from Main2 we simply specify in the LoadValue prompt which category we want to load from
So ya hopefully this gives you guys an idea how text files work, and how you can store data in it. In alot of ways its more simple and easier to use
than SQL tables, since it can create its own categories on the fly. Also notice its only the right column of data that can be searched and edited, the left column stays permanent.
When you think about it, you probably can create more sophisticated data entries
with text files than with SQL, and read them must quicker. something like...
Enjoy and please let me no if i made an error's. I don't own a server anymore, so I can only go off my head if this stuff is valid anymore lol
However, sometimes it is easier to use a more simple method. I noticed there was no posted tutorial on this
so I figured I would make one, it might help some of you make more simple scripts that allow things to be saved
without resorting to make a table in SQL.
First off, what can a .txt file store? It can basically store 2 unique columns of data, they can be numbers
or words. You can add, subtract, update, edit, load things from text files. Unfortunately with that limitation
you can't store 3+ columns of data in a text file (to my knowledge, correct me if i am wrong ) However, you can
seperate columns out, so in retrospect you can actually store alot more data then you think.. I'll explain below
Lets start off with some terms to no, i think you no probably in general what these things do. so lets start off
with an example on how to use them.
SaveValue
Loadvalue
addnamelist
checknamelist
!CheckNameList
now lets start a script in 00default.txt that check's if its a new player or not, and then gives the user a custom welcome message
Code:
#IF
!CheckNameList newplayers.txt ;if the name isnt in the newplayers list
#ACT
AddNameList newplayers.txt ;then we add the name to the list
SaveValue "QuestDiary\newplayermessage.txt" Main %USERNAME noob ;notice we use a new text file to save this data. name searching must be in a seperate
text file from the data entry. Notice the format of saving. Main tell's the category
Username tell's us the player name, noob is the message.
goto @@changemessage
#ELSEACT
LoadValue A1 "QuestDiary\newplayermessage.txt" Main %USERNAME
#SAY
Welcome back <$OUTPUT(A1)>\
<Change Message/@@changemessage>\
<Close/@Exit>\
[@@changemessage]
#ACT
Mov A2 %INPUTSTR
SaveValue A2 "QuestDiary\newplayermessage.txt" Main %USERNAME
#SAY
Next time you login, your welcome message will say\\
Welcome back <$OUTPUT(A1)>\\
<Close/@Exit>\
If this is done properly, you can go into newplayermessage.txt
and you should see something like this...
Code:
[Main]
Inflikted=noob
Noname=you idiot
Now as I mentioned earlier, you can indeed save multiple categories in the same text file, I won't draw out another example for it
but say we want to add another category that saves numbers. Unlike SQL we would have to go back and make a new table. Not with .txt files
Mir3 should simply add in the category for you.
Say I want to store a certain number along with their username in the same text file to save space. I could do something like..
Code:
SaveValue "QuestDiary\newplayermessage.txt" Main2 %USERNAME 89
and when we want to call up data from Main2 we simply specify in the LoadValue prompt which category we want to load from
Code:
LoadValue D1 "QuestDiary\newplayermessage.txt" Main2 %USERNAME
So ya hopefully this gives you guys an idea how text files work, and how you can store data in it. In alot of ways its more simple and easier to use
than SQL tables, since it can create its own categories on the fly. Also notice its only the right column of data that can be searched and edited, the left column stays permanent.
When you think about it, you probably can create more sophisticated data entries
with text files than with SQL, and read them must quicker. something like...
Code:
#ACT
LoadValue D1 "QuestDiary\newplayermessage.txt" Main2 %USERNAME
LoadValue D2 "QuestDiary\newplayermessage.txt" Main3 %USERNAME
LoadValue D3 "QuestDiary\newplayermessage.txt" Main4 %USERNAME
LoadValue D4 "QuestDiary\newplayermessage.txt" Main5 %USERNAME
LoadValue D5 "QuestDiary\newplayermessage.txt" Main6 %USERNAME
Enjoy and please let me no if i made an error's. I don't own a server anymore, so I can only go off my head if this stuff is valid anymore lol
Last edited: