Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SavePlayer Faster
#1
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.
Reply
#2
Any side affects to this?
Reply
#3
Without it, it will save all your characters although you are only online with one.
Reply
#4
ooh, simple but meaningful fix - thankies 8)
Reply
#5
Link it in with HighIndex and you'll only have to save 5 players a time Wink
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#6
Note, this makes you unable to delete chars.
Reply
#7
I can still delete my chars, maybe I did something to fix it dunno.
Reply
#8
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.
Reply
#9
I thought there was a problem with deleting characters anyway...
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#10
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.
Reply
#11
Fix?
Reply
#12
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)