17-10-2006, 03:57 PM
I'll get straight to the point. This tutorial doesn't cut down on useless information getting saved. Right now, the server saves every player every 10 minutes at the same time.
What this tutorial will do, is make the server save each player individually. Just one player at a time. It makes a pretty big difference when you've got more than a dozen or so players online at once.
Tutorial Difficulty: 1/5
Things to change:
* frmServer and frmServer Code
* modGlobals
* modGeneral
Lets begin in modGlobal. Add this code anywhere you please in modGlobal.
That was simple. Lets move on to frmServer.
Start by adding a new timer. Name the timer PlayerTimer. Enable it to False, and set the interval to 10000.
Were not finished with frmServer yet, but for now lets browse over to modGeneral.
Find and replace this code:
With this code here:
Sub PlayerSaveTimer was saving every player more or less at the same time every 10 minutes. What we did, is change the sub to activate a new timer every 10 minutes. Look for If MinPassed >= 10 Then in the code because I recommend changing that 10 to a higher number such as 120. That would make our new timer activate every two hours.
Anyways, were finished with modGeneral, and as I mentioned earlier, were gonna go back and finish frmServer now.
Open up the frmServer code, and add this code at the bottom:
If you remember, we set this timers interval to 10000, or 10 seconds. This new timer saves 1 player every 10 seconds until every player has been saved. This should greatly reduce stress caused by the player save.
Credits go to PsychoBoy for original concept.
What this tutorial will do, is make the server save each player individually. Just one player at a time. It makes a pretty big difference when you've got more than a dozen or so players online at once.
Tutorial Difficulty: 1/5
Things to change:
* frmServer and frmServer Code
* modGlobals
* modGeneral
Lets begin in modGlobal. Add this code anywhere you please in modGlobal.
Code:
'Player Saving Constants
Global PlayerI As Byte
That was simple. Lets move on to frmServer.
Start by adding a new timer. Name the timer PlayerTimer. Enable it to False, and set the interval to 10000.
Were not finished with frmServer yet, but for now lets browse over to modGeneral.
Find and replace this code:
Code:
Sub PlayerSaveTimer()
Static MinPassed As Long
Dim i As Long
MinPassed = MinPassed + 1
If MinPassed >= 10 Then
If TotalOnlinePlayers > 0 Then
Call TextAdd(frmServer.txtText, "Saving all online players...", True)
Call GlobalMsg("Saving all online players...", Pink)
For i = 1 To MAX_PLAYERS
If IsPlaying(i) Then
Call SavePlayer(i)
End If
DoEvents
Next i
End If
MinPassed = 0
End If
End Sub
With this code here:
Code:
Sub PlayerSaveTimer()
Static MinPassed As Long
Dim i As Long
MinPassed = MinPassed + 1
If MinPassed >= 10 Then
If TotalOnlinePlayers > 0 Then
PlayerI = 1
frmServer.PlayerTimer.Enabled = True
frmServer.tmrPlayerSave.Enabled = False
End If
MinPassed = 0
End If
End Sub
Sub PlayerSaveTimer was saving every player more or less at the same time every 10 minutes. What we did, is change the sub to activate a new timer every 10 minutes. Look for If MinPassed >= 10 Then in the code because I recommend changing that 10 to a higher number such as 120. That would make our new timer activate every two hours.
Anyways, were finished with modGeneral, and as I mentioned earlier, were gonna go back and finish frmServer now.
Open up the frmServer code, and add this code at the bottom:
Code:
Private Sub PlayerTimer_Timer()
Dim i As Long
If PlayerI = MAX_PLAYERS Then
PlayerI = 1
PlayerTimer.Enabled = False
tmrPlayerSave.Enabled = True
End If
End Sub
If you remember, we set this timers interval to 10000, or 10 seconds. This new timer saves 1 player every 10 seconds until every player has been saved. This should greatly reduce stress caused by the player save.
Credits go to PsychoBoy for original concept.