![]() |
Binary Accounts... The Easy Way - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Binary Accounts... The Easy Way (/showthread.php?tid=521) |
Binary Accounts... The Easy Way - Obsidian - 22-12-2006 Alright as many of you (especially Sise ![]() Tutorial Difficulty 2/5 - Easy Okay so in Dave's tutorial (who i'm not downplaying.. dave is my hero), you would store every value individually into the binary file after you opened it, which is not a bad way of doing it. My way however, there is one simple line to both load and save, after the binary file is open. The only current drawback, however, is that it also stores your AccountVariables (the temoraries), into your account along with all of your account stuff. Not that it's a huge deal... you store like an extra 20 Bytes or something per account... but if you want... (since i know that Dave will kill me if i don't mention it), is create another UDT that's something like Type TempPlayerRec, store the info there, and pull it from that rather than the Account or PlayerRecs. But, without further adieu... onto the easy tutorial. First would be the... Save Player Sub. Now since this is all incredibly easy i'm not going to explain line by line, but simply post the code. Code: Sub SavePlayer(ByVal index As Long) However, the Line, "Put #f, , Player(index)" should be of particular interest... that's the line that saves EVERYTHING. It basically goes through the UDT line at a time and stores it all into the binary file. After it has completed storing it... it closes the file. See how easy that was!!!!!!!! Okay same thing, but using get, rather than put... yep, you guessed it! LoadPLayer!!!!! Code: Sub LoadPlayer(ByVal index As Long, ByVal name As String) Okay now, these are only minor adjustments that need to be made to these other files, just so it verifies your account data and a few other things, and whalla... you're done! Replace the entire Function AccountExist, with this code: Code: Function AccountExist(ByVal name As String) As Boolean Replace the entire PasswordOK Function, with this code: Code: Function PasswordOK(ByVal name As String, ByVal Password As String) As Boolean Alright, that's all for this lesson. I hope this helps you out. I'd like to give all credit for this to Dave. Had he not written the original tutorial, i probably wouldn't have made an attempt to understand any of this stuff. Post any questions/comments you might have. - TheRealDamien - 22-12-2006 How wonderful this is I think the main problem people have with binary is making an editor correctly. - Xlithan - 22-12-2006 Yep, making an editor for these types of files is more tricky, since you have to be more specific when reading from it. - TheRealDamien - 22-12-2006 Yeah personally ive been through hell and back trying to do this lol... - Gilgamesch - 03-01-2007 sry for bumping this post up, but, did anyone find a way for a editor he wants to share? ^^ - William - 30-01-2007 Moved to Optimizations. - Obsidian - 10-02-2007 Yeah, for those of you wondering what dave was talking about... you can (in the Save/Load subs) simply just add this to it on the save player add this... Code: dim i as byte ' assuming you don't allow them to have more than 255 characters then change the Put #f, , Player(index) to this... Code: Put #f, , Trim$(Player(Index).Name) Do the same thing for the Load Sub, but use the Get Function, not put. Fairly simple, and it'll save you an extra like... 10-30 bytes per account... not a huge deal... but if you know dave.... every byte counts. - Robin - 15-03-2007 It's an old, old, terribly old topic, but if you are lazy, simply add a quick button server side and make it pop-up an input box, make it so any name typed in gets admin access. This will save you having a crappy editor, and can also be commented when compiling, so only you can do it. |