Your banner could be here
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    LOMCN Senior Member Inflikted's Avatar
    Join Date
    Aug 2003
    Posts
    256

    Inflikted's Idiot Guide to .txt Manipulation

    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

    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 by Inflikted; 10-11-2008 at 04:16 AM.

  2. #2
    Mir3 Guru - Sting3G idaBigA's Avatar
    Join Date
    Oct 2003
    Location
    Stoke, UK
    Posts
    1,825

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Nice post.. a lot of people overlook text files now that SQL is being used more and more.

    After looking at the VE files, I think thats all they used, and they have system's Equal in complexity to the ones using SQL. I suppose its just a matter on which one you prefer.

    I dunno about how much resources it uses to update SQL as compared to the file handler that the server uses.. in fact, I would have no idea how to ever go about check it lol.. I am gonna shut up now..

    Anyway.. Good Post.. Rep Up!
    www.sting3g.com - PhoenixRising Server & Sting3G Server

  3. #3
    mapadale
    Guest mapadale's Avatar

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Cheers for that Inflikted, now stickied.

  4. #4
    LOMCN Senior Member Inflikted's Avatar
    Join Date
    Aug 2003
    Posts
    256

    Re: Inflikted's Idiot Guide to .txt Manipulation

    for me it was actually kyeron who triggered the idea to do this. since everything he has done can be created with text file database and its much easier for a new scripter. but i guess if you notice in alot of the chinese scripts that no one bothers to translate, they rely heavily on .txt storage aswell, rather than SQL. i suppose the only benefit you get with the SQL storage is adding multiple entries at the same time, while you can't do that with text files. and generally speaking.. i think resource wise it probably won't be a big difference unless you heavily mod your server with alot SQL scripting.. but i doubt anyone here has done this so its not a big deal
    Last edited by Inflikted; 10-11-2008 at 03:22 PM.

  5. #5
    Mir3 Guru - Sting3G idaBigA's Avatar
    Join Date
    Oct 2003
    Location
    Stoke, UK
    Posts
    1,825

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Quote Originally Posted by Inflikted View Post
    for me it was actually kyeron who triggered the idea to do this. since everything he has done can be created with text file database and its much easier for a new scripter. but i guess if you notice in alot of the chinese scripts that no one bothers to translate, they rely heavily on .txt storage aswell, rather than SQL. i suppose the only benefit you get with the SQL storage is adding multiple entries at the same time, while you can't do that with text files. and generally speaking.. i think resource wise it probably won't be a big difference unless you heavily mod your server with alot SQL scripting.. but i doubt anyone here has done this so its not a big deal

    Oops..

    I have all my Quests, Pot Storage, Booty Storage, Events, and a few more items all use SQL..

    Saying that I also, use quite a bit of Text storage as well, i.e. When people die, it adds to a text doc so I can tell exactly how many times everyone has died.. Sabuk War Deaths recorded.. and random other stuff..

    There is a quite a bit you can do with the files, but unless someone makes an open source server we will always be stopped short of making masterpieces.

    I don't notice any server lag at all, so I suppose either way is good.
    www.sting3g.com - PhoenixRising Server & Sting3G Server

  6. #6
    LOMCN Rookie Cricket1650's Avatar
    Join Date
    Apr 2008
    Posts
    66

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Nice thanks man.. didn't know how to do this before.. but than again that's what tutorials/guides are for.

  7. #7
    Mad Dog Geo Geordiehc's Avatar
    Join Date
    Jul 2007
    Location
    Redditch, UK
    Posts
    2,824

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Nice 1 m8, can Username be changed with like guildname etc?
    If this Post has been helpful then please click the +rep symbol on the bottom left to show your appreciation!

    LOM 3 Community On ********!

    http://www.*************/groups/113381352098871/
    Stay In Touch With Friends Whatever Server You Play

    I do not answer server help questions via PM. PM'ing me will not get you a quicker answer than posting.

  8. #8
    LOMCN Senior Member Inflikted's Avatar
    Join Date
    Aug 2003
    Posts
    256

    Re: Inflikted's Idiot Guide to .txt Manipulation

    indeed, you can put whatever you want there.

  9. #9
    Mad Dog Geo Geordiehc's Avatar
    Join Date
    Jul 2007
    Location
    Redditch, UK
    Posts
    2,824

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Sorry that im noob been so long since i messed with mir lol
    #ACT
    LoadValue D1 "QuestDiary\guildpoints.txt" Main %Guildname
    Inc %D1 1
    SaveValue "QuestDiary\guildpoints.txt" Main %Guildname %D1
    #SAY
    %GUILDNAME now has <OUTPUT(D1)> point('s)\
    Something like that would work instead of Using SQL for guild points?

    EDIT: dont know what im doing wrong but im having real problems with guild calling, sometimes it works with <$GUILD> sometimes it doesnt and it woont work at all with %GUILD any ideasplease im totally stuck other than that iv got a .txt version of guild points that i can release when finished lol
    Last edited by Geordiehc; 12-11-2008 at 11:27 PM.
    If this Post has been helpful then please click the +rep symbol on the bottom left to show your appreciation!

    LOM 3 Community On ********!

    http://www.*************/groups/113381352098871/
    Stay In Touch With Friends Whatever Server You Play

    I do not answer server help questions via PM. PM'ing me will not get you a quicker answer than posting.

  10. #10
    LOMCN Rookie Cricket1650's Avatar
    Join Date
    Apr 2008
    Posts
    66

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Hey so say I wanted to check the script to see if the username is there and if it is the script will end. If its not there i want it to continue the script and save their name to the script. How would i do that?

  11. #11
    LOMCN Senior Member Inflikted's Avatar
    Join Date
    Aug 2003
    Posts
    256

    Re: Inflikted's Idiot Guide to .txt Manipulation

    read my tutorial cricket, the thing your asking for is already in there

    and geo... you should use %GUILDNAME in the ACT part of the script and i believe <$GUILD> or <$GUILDNAME> for the SAY part's of the script. i cant confirm this though, since i dont have a server.

  12. #12
    LOMCN Rookie Cricket1650's Avatar
    Join Date
    Apr 2008
    Posts
    66

    Re: Inflikted's Idiot Guide to .txt Manipulation

    i read it and put it in the script but even with the name in the .txt the script would still continue

  13. #13
    LOMCN Senior Member Inflikted's Avatar
    Join Date
    Aug 2003
    Posts
    256

    Re: Inflikted's Idiot Guide to .txt Manipulation

    try to use
    #IF
    CheckNameList thetext.txt
    #ACT
    break
    #ELSEACT
    Addnamelist thetext.txt


    try that out. though the other way should work fine also i think.

  14. #14
    Mad Dog Geo Geordiehc's Avatar
    Join Date
    Jul 2007
    Location
    Redditch, UK
    Posts
    2,824

    Re: Inflikted's Idiot Guide to .txt Manipulation

    How would u use CHECKNAMELIST for a guild? i dont think this is going to be possible to make a guild form of the script lol
    If this Post has been helpful then please click the +rep symbol on the bottom left to show your appreciation!

    LOM 3 Community On ********!

    http://www.*************/groups/113381352098871/
    Stay In Touch With Friends Whatever Server You Play

    I do not answer server help questions via PM. PM'ing me will not get you a quicker answer than posting.

  15. #15
    Mir3 Guru - Sting3G idaBigA's Avatar
    Join Date
    Oct 2003
    Location
    Stoke, UK
    Posts
    1,825

    Re: Inflikted's Idiot Guide to .txt Manipulation

    Its exactly the same as using USERNAME, just replace USERNAME with GUILDNAME..

    Here..

    Code:
    #ACT
       Mov A0 %GUILDNAME
       Mov A1 "Value A to Save"
       Mov A2 "Value B to Save"
       Mov A3 "Value C to Save"
       Mov A4 "Value D to Save"
       SaveValue "QuestDiary\System\TextDoc.txt" [%A0] SectionA %A1
       SaveValue "QuestDiary\System\TextDoc.txt" [%A0] SectionB %A2
       SaveValue "QuestDiary\System\TextDoc.txt" [%A0] SectionC %A3
       SaveValue "QuestDiary\System\TextDoc.txt" [%A0] SectionD %A4
    This will save the following in the files TextDoc.txt

    Code:
    [GUILDNAME1]
    SectionA=Value A to Save
    SectionB=Value B to Save
    SectionC=Value C to Save
    SectionD=Value D to Save
    [GUILDNAME2]
    SectionA=Value A to Save
    SectionB=Value B to Save
    SectionC=Value C to Save
    SectionD=Value D to Save
    etc
    To get the info back out.. putting whichever item you want.. into a Variable (in this case A1)

    Code:
    #ACT
       Mov A0 %GUILDNAME
       LoadValue A1 "QuestDiary\System\TextDoc.txt" [%A0] SectionA
    To check if the Guild already exists in this file.. A1 will return no value if SectionA does not exist (or is empty, if this is not acceptable, see below). So it must not exist

    Code:
    #ACT
       Mov  A1  ""
       Mov A0 %GUILDNAME
       LoadValue A1 "QuestDiary\System\TextDoc.txt" [%A0] SectionA
    #IF
       Equal  A1 ""
    #SAY
    This guild does not exist...
    If "SectionA" can be empty then you need to setup another variable to say it exists.. i.e. one that you will not use for any other purpose than checking it is available.

    Code:
    #ACT
       Mov A0 %GUILDNAME
       SaveValue "QuestDiary\System\TextDoc.txt" [%A0] GuildExists 1
    And then to check it..
    Code:
    #ACT
       Mov D1 0
       Mov  A1  ""
       Mov A0 %GUILDNAME
       LoadValue D1 "QuestDiary\System\TextDoc.txt" [%A0] GuildExists
    #IF
       Equal D1 0
    #SAY
    Guild does not exist..
    And.. almost ANYTHING is possible, if it isn't capable of being done internally with Mir, just make a small add on App that will check things, or manipulate data for you to then grab from text docs or SQL..
    www.sting3g.com - PhoenixRising Server & Sting3G Server

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •