Mirage Source http://miragesource.net/forums/ |
|
Server Saving Optimization http://miragesource.net/forums/viewtopic.php?f=210&t=654 |
Page 1 of 1 |
Author: | Rian [ Tue Oct 17, 2006 3:57 pm ] |
Post subject: | Server Saving Optimization |
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. 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 If IsPlaying(PlayerI) Then Call SavePlayer(PlayerI) Call PlayerMsg(PlayerI, GetPlayerName(PlayerI) & ", you have been saved.", BrightGreen) End If PlayerI = PlayerI + 1 End If 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. |
Author: | William [ Fri Oct 20, 2006 7:44 pm ] |
Post subject: | |
Didn't see this before I made my tutorial. This is another way that is very affective. |
Author: | Xlithan [ Thu Jan 18, 2007 5:31 pm ] |
Post subject: | |
There's a timer called tmrPlayerSave which has a 60 second interval. It called Sub PlayerSaveTimer() Should I delete this? I also get this run-time (Subscript out of range) Code: IsPlaying = IsConnected(Index) And Player(Index).InGame
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |