Mirage Source http://www.miragesource.net/forums/ |
|
Q&A http://www.miragesource.net/forums/viewtopic.php?f=201&t=720 |
Page 1 of 2 |
Author: | DarkX [ Sun Nov 05, 2006 10:09 pm ] |
Post subject: | Q&A |
Hey, I was wondering if someone could assist me into making it so that when you make a new account it creates a folder(named after account) and all your characters are saved into it, as well as your mail, offlinepm's and other things like that. Thanks in advance, later. |
Author: | Misunderstood [ Mon Nov 06, 2006 2:14 am ] |
Post subject: | |
Look at how MS does other things... MS already has examples for creating folders. Look at how the Maps folder is created. Saving characters, it saves it to one file in a loop. Just change the filename in each loop.(Unless you want the characters all in one file, I'm not real sure what you want) In that case, its just adding in the account name as the folder to the filename. And do the reverse for loading... |
Author: | Lea [ Mon Nov 06, 2006 2:51 am ] |
Post subject: | |
That's actually a good idea that I haven't thought of before! Although I think better would be something like a zip archive, instead of a folder Elaboration follows. Zip archives are essentially compressed folders. Storing everything seperate will result an average of 1KB per file added, plus the file header you need to add to each (10 bytes, maybe). That, teamed with not needing most of the information at any time, makes it impractical to store thousands of tiny, tiny files. Tiny files are what messes up computers. They don't store well, and they take forever to sort. (Ever try virus scanning on a computer with a server on it? takes FOREVER!) You could, however, compress all this stuff into a single zip file per account, and uncompress it only when the player logs in. When they log out, and you have a moment (enough processor time, it's not a crucial thing to do so wait until you have a moment) you can quick zip it up automatically and boom, all set. This would also make moving accounts from one to another server very quick. Good luck, and thanks for the idea! |
Author: | DarkX [ Mon Nov 06, 2006 3:25 am ] |
Post subject: | |
Well, what I'm looking to do is. Make it so that when a account is made it's stored in a folder which is named after the account; in it are seperate character files like on Elysium. And I'm trying to make a message box; like if player is offline and someone try's to send a message it goes into the message box(which would actually in turn be one list of messages(.ini) from anyone who pm's you) and you can click save message and it puts it into another list and a seperate .ini file. If that makes any sense, if I can figure it out I'll make it work with e-mail. |
Author: | Lea [ Mon Nov 06, 2006 3:39 am ] |
Post subject: | |
I understand what you're trying to do, I was suggesting an expansion to it |
Author: | DarkX [ Mon Nov 06, 2006 12:03 pm ] |
Post subject: | |
I was just making sure that Mis or anyone else understood, I like your idea with the .zips, but not sure on how to go about that. And for the time being how do you save them as there own folder? what's the extension? or what do you type in? |
Author: | Lea [ Mon Nov 06, 2006 12:41 pm ] |
Post subject: | |
you can create any extention you want, really. If you want to do it with INI's like Mirage currently does, I would use that as a template. |
Author: | DarkX [ Mon Nov 06, 2006 1:10 pm ] |
Post subject: | |
I forget which engine it was but it saves the characters into seperate .ini's, I know the extension for them. My biggest thing is I want it to create a folder for each Account, but I don't know the extension for that. I mean I found this http://www.ace.net.nz/tech/TechFileFormat.html#f but I'm not sure what I'm looking for |
Author: | Obsidian [ Mon Nov 06, 2006 10:29 pm ] |
Post subject: | |
there is no "extension" to make a folder... folders don't have extensions... just do this in the "addaccount" sub Call MkDir(App.Path & "\accounts\" & Trim$(Player(Index).Login)) then, just adjust the save player sub, so it uses this file... App.Path & "\accounts\" & Trim$(Player(Index).Login) & "\" & Trim$(Player(Index).Login) & ".ini" then it'll create a folder, and store your player's account (ini, i assume) in that folder) |
Author: | DarkX [ Tue Nov 07, 2006 3:47 pm ] |
Post subject: | |
Ok Obsidian it somewhat worked, it saves into a file with the .ini inside it, now I just have to figure out how to make it load And I tried this Code: FileName = App.Path & "\Accounts\" & Trim(Name) & "\" & Trim(Name) & ".ini" but it says account does not exist. Also I tried thisCode: FileName = App.Path & "\Accounts\" & Trim(Player(Index).Name) & "\" & Trim(Name) & ".ini" which does the same thing as the first one.
|
Author: | Obsidian [ Tue Nov 07, 2006 4:45 pm ] |
Post subject: | |
Do you see where you made your mistake? when they login, they aren't set as "Name", they're set as index... (a #), so you need to make BOTH of them a Trim(Player(index).Name) so it should look similar to the second one, but BOTH should have the player(index).name so it should be like this... Code: FileName = App.Path & "\Accounts\" & Trim(Player(Index).Name) & "\" & Trim(Player(index).Name) & ".ini"
See the difference? |
Author: | DarkX [ Wed Nov 08, 2006 3:54 pm ] |
Post subject: | |
actually I tried that last night, and it didn't work either. |
Author: | Lea [ Wed Nov 08, 2006 8:11 pm ] |
Post subject: | |
Can you post the code you're using to _save_ the file please? |
Author: | DarkX [ Thu Nov 09, 2006 2:44 pm ] |
Post subject: | |
All ServerSide moddatabase Code: Sub AddAccount(ByVal Index As Long, ByVal Name As String, ByVal Password As String)
Dim i As Long Player(Index).Login = Name Player(Index).Password = Password For i = 1 To MAX_CHARS Call ClearChar(Index, i) Next i Call SavePlayer(Index) Call MkDir(App.Path & "\accounts\" & Trim$(Player(Index).Login)) End Sub Sub SavePlayer(ByVal Index As Long) Dim FileName As String Dim i As Long Dim n As Long FileName = App.Path & "\accounts\" & Trim$(Player(Index).Login) & "\" & Trim$(Player(Index).Login) & ".ini" Call PutVar(FileName, "GENERAL", "Login", Trim(Player(Index).Login)) Call PutVar(FileName, "GENERAL", "Password", Trim(Player(Index).Password)) For i = 1 To MAX_CHARS ' General Call PutVar(FileName, "CHAR" & i, "Name", Trim(Player(Index).Char(i).Name)) Call PutVar(FileName, "CHAR" & i, "Class", STR(Player(Index).Char(i).Class)) Call PutVar(FileName, "CHAR" & i, "Sex", STR(Player(Index).Char(i).Sex)) Call PutVar(FileName, "CHAR" & i, "Sprite", STR(Player(Index).Char(i).Sprite)) Call PutVar(FileName, "CHAR" & i, "Level", STR(Player(Index).Char(i).Level)) Call PutVar(FileName, "CHAR" & i, "Exp", STR(Player(Index).Char(i).Exp)) Call PutVar(FileName, "CHAR" & i, "Access", STR(Player(Index).Char(i).Access)) Call PutVar(FileName, "CHAR" & i, "PK", STR(Player(Index).Char(i).PK)) Call PutVar(FileName, "CHAR" & i, "Guild", STR(Player(Index).Char(i).Guild)) ' Vitals Call PutVar(FileName, "CHAR" & i, "HP", STR(Player(Index).Char(i).HP)) Call PutVar(FileName, "CHAR" & i, "MP", STR(Player(Index).Char(i).MP)) Call PutVar(FileName, "CHAR" & i, "SP", STR(Player(Index).Char(i).SP)) ' Stats Call PutVar(FileName, "CHAR" & i, "STR", STR(Player(Index).Char(i).STR)) Call PutVar(FileName, "CHAR" & i, "DEF", STR(Player(Index).Char(i).DEF)) Call PutVar(FileName, "CHAR" & i, "SPEED", STR(Player(Index).Char(i).SPEED)) Call PutVar(FileName, "CHAR" & i, "MAGI", STR(Player(Index).Char(i).MAGI)) Call PutVar(FileName, "CHAR" & i, "POINTS", STR(Player(Index).Char(i).POINTS)) ' Worn equipment Call PutVar(FileName, "CHAR" & i, "ArmorSlot", STR(Player(Index).Char(i).ArmorSlot)) Call PutVar(FileName, "CHAR" & i, "WeaponSlot", STR(Player(Index).Char(i).WeaponSlot)) Call PutVar(FileName, "CHAR" & i, "HelmetSlot", STR(Player(Index).Char(i).HelmetSlot)) Call PutVar(FileName, "CHAR" & i, "ShieldSlot", STR(Player(Index).Char(i).ShieldSlot)) ' Check to make sure that they aren't on map 0, if so reset'm If Player(Index).Char(i).Map = 0 Then Player(Index).Char(i).Map = START_MAP Player(Index).Char(i).x = START_X Player(Index).Char(i).y = START_Y End If ' Position Call PutVar(FileName, "CHAR" & i, "Map", STR(Player(Index).Char(i).Map)) Call PutVar(FileName, "CHAR" & i, "X", STR(Player(Index).Char(i).x)) Call PutVar(FileName, "CHAR" & i, "Y", STR(Player(Index).Char(i).y)) Call PutVar(FileName, "CHAR" & i, "Dir", STR(Player(Index).Char(i).Dir)) ' Inventory For n = 1 To MAX_INV Call PutVar(FileName, "CHAR" & i, "InvItemNum" & n, STR(Player(Index).Char(i).Inv(n).Num)) Call PutVar(FileName, "CHAR" & i, "InvItemVal" & n, STR(Player(Index).Char(i).Inv(n).Value)) Call PutVar(FileName, "CHAR" & i, "InvItemDur" & n, STR(Player(Index).Char(i).Inv(n).Dur)) Next n ' Spells For n = 1 To MAX_PLAYER_SPELLS Call PutVar(FileName, "CHAR" & i, "Spell" & n, STR(Player(Index).Char(i).Spell(n))) Next n Next i End Sub Sub LoadPlayer(ByVal Index As Long, ByVal Name As String) Dim FileName As String Dim i As Long Dim n As Long Call ClearPlayer(Index) FileName = App.Path & "\Accounts\" & Trim(Player(index).Name) & "\" & Trim(Player(index).Name) & ".ini" Player(Index).Login = GetVar(FileName, "GENERAL", "Login") Player(Index).Password = GetVar(FileName, "GENERAL", "Password") For i = 1 To MAX_CHARS ' General Player(Index).Char(i).Name = GetVar(FileName, "CHAR" & i, "Name") Player(Index).Char(i).Sex = Val(GetVar(FileName, "CHAR" & i, "Sex")) Player(Index).Char(i).Class = Val(GetVar(FileName, "CHAR" & i, "Class")) Player(Index).Char(i).Sprite = Val(GetVar(FileName, "CHAR" & i, "Sprite")) Player(Index).Char(i).Level = Val(GetVar(FileName, "CHAR" & i, "Level")) Player(Index).Char(i).Exp = Val(GetVar(FileName, "CHAR" & i, "Exp")) Player(Index).Char(i).Access = Val(GetVar(FileName, "CHAR" & i, "Access")) Player(Index).Char(i).PK = Val(GetVar(FileName, "CHAR" & i, "PK")) Player(Index).Char(i).Guild = Val(GetVar(FileName, "CHAR" & i, "Guild")) ' Vitals Player(Index).Char(i).HP = Val(GetVar(FileName, "CHAR" & i, "HP")) Player(Index).Char(i).MP = Val(GetVar(FileName, "CHAR" & i, "MP")) Player(Index).Char(i).SP = Val(GetVar(FileName, "CHAR" & i, "SP")) ' Stats Player(Index).Char(i).STR = Val(GetVar(FileName, "CHAR" & i, "STR")) Player(Index).Char(i).DEF = Val(GetVar(FileName, "CHAR" & i, "DEF")) Player(Index).Char(i).SPEED = Val(GetVar(FileName, "CHAR" & i, "SPEED")) Player(Index).Char(i).MAGI = Val(GetVar(FileName, "CHAR" & i, "MAGI")) Player(Index).Char(i).POINTS = Val(GetVar(FileName, "CHAR" & i, "POINTS")) ' Worn equipment Player(Index).Char(i).ArmorSlot = Val(GetVar(FileName, "CHAR" & i, "ArmorSlot")) Player(Index).Char(i).WeaponSlot = Val(GetVar(FileName, "CHAR" & i, "WeaponSlot")) Player(Index).Char(i).HelmetSlot = Val(GetVar(FileName, "CHAR" & i, "HelmetSlot")) Player(Index).Char(i).ShieldSlot = Val(GetVar(FileName, "CHAR" & i, "ShieldSlot")) ' Position Player(Index).Char(i).Map = Val(GetVar(FileName, "CHAR" & i, "Map")) Player(Index).Char(i).x = Val(GetVar(FileName, "CHAR" & i, "X")) Player(Index).Char(i).y = Val(GetVar(FileName, "CHAR" & i, "Y")) Player(Index).Char(i).Dir = Val(GetVar(FileName, "CHAR" & i, "Dir")) ' Check to make sure that they aren't on map 0, if so reset'm If Player(Index).Char(i).Map = 0 Then Player(Index).Char(i).Map = START_MAP Player(Index).Char(i).x = START_X Player(Index).Char(i).y = START_Y End If ' Inventory For n = 1 To MAX_INV Player(Index).Char(i).Inv(n).Num = Val(GetVar(FileName, "CHAR" & i, "InvItemNum" & n)) Player(Index).Char(i).Inv(n).Value = Val(GetVar(FileName, "CHAR" & i, "InvItemVal" & n)) Player(Index).Char(i).Inv(n).Dur = Val(GetVar(FileName, "CHAR" & i, "InvItemDur" & n)) Next n ' Spells For n = 1 To MAX_PLAYER_SPELLS Player(Index).Char(i).Spell(n) = Val(GetVar(FileName, "CHAR" & i, "Spell" & n)) Next n Next i End Sub the only thing that doesn't work is loading the account from the folder, cuz it saves it with the .ini's inside but, it tells you the account does not exist when you try to login. |
Author: | Obsidian [ Thu Nov 09, 2006 4:49 pm ] |
Post subject: | |
did you try checking the accounexist function |
Author: | Lea [ Thu Nov 09, 2006 9:56 pm ] |
Post subject: | |
Filename should be Player(index).login for both saving and loading. |
Page 1 of 2 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |