Mirage Source
SavePlayer Faster - 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: SavePlayer Faster (/showthread.php?tid=49)



SavePlayer Faster - grimsk8ter11 - 01-06-2006

Originally posted by Dragoons Master

Very simple tutorial. I was testing my server on a P2(455Mhz) and it was veery lagued, but thats not the point. When I tried to create an account from my website account creation, it taked sooo long creating it, so I maded a veeery simple modification, and now it creates the account praticly instantly.
It just saves the player you are using(PlayerNum), so do this:
ONLY SERVER SIDE

modDatabase:
Sub SavePlayer:
Replace:

Code:
For I = 1 To MAX_CHARS

with:

Code:
For I = 1 To MAX_CHARS
        If Player(Index).CharNum = I Then
and replace:

Code:
Next I
with:

Code:
End If
    Next I

This will make the server saves only the char you had played, and on the account creation, it will save only the account information(3 or 4 lines) xD
Simple and usefull.


Re: SavePlayer Faster - Coke - 02-07-2007

Any side affects to this?


Re: SavePlayer Faster - William - 02-07-2007

Without it, it will save all your characters although you are only online with one.


Re: SavePlayer Faster - Coke - 02-07-2007

ooh, simple but meaningful fix - thankies 8)


Re: SavePlayer Faster - Robin - 02-07-2007

Link it in with HighIndex and you'll only have to save 5 players a time Wink


Re: SavePlayer Faster - Rezeyu - 03-07-2007

Note, this makes you unable to delete chars.


Re: SavePlayer Faster - William - 03-07-2007

I can still delete my chars, maybe I did something to fix it dunno.


Re: SavePlayer Faster - Matt - 03-07-2007

I can still delete my characters too. I THINK there may have been an issue with it, but I added this so long ago, I'm not really sure.


Re: SavePlayer Faster - Robin - 03-07-2007

I thought there was a problem with deleting characters anyway...


Re: SavePlayer Faster - Rezeyu - 03-07-2007

When you delete a char, it clears the char, setting everythingk.. blank.

Then it calls save player.
So that it saves the blank data over the old data.


But with this, I was unable to do that, because it checks if the char is being used.
And in a menu, it's not being used.

So it says that you have no currently playing chars, and skips the whole save.
Me and SMChronos had the error.


Re: SavePlayer Faster - Coke - 03-07-2007

Fix?


Re: SavePlayer Faster - Cruzn - 03-07-2007

Fox Wrote:Fix?
I use this:
Code:
Sub SavePlayer(ByVal Index As Long, ByVal cNum as Byte)
Dim FileName As String
Dim n As Long

    cNum = int(cNum)
    FileName = App.Path & "\accounts\" & Trim(Player(Index).Login) & ".ini"
    
    Call PutVar(FileName, "CHAR" & cNum, "Name", Trim(Player(Index).Char(cNum).Name))
    Call PutVar(FileName, "CHAR" & cNum, "Class", STR(Player(Index).Char(cNum).Class))
    Call PutVar(FileName, "CHAR" & cNum, "Sex", STR(Player(Index).Char(cNum).Sex))
...

End Sub
Code:
Call SavePlayer(Index, CharNum)
Just the way I do it, =P. May not be the best.