| Mirage Source http://miragesource.net/forums/ |
|
| /save http://miragesource.net/forums/viewtopic.php?f=210&t=1144 |
Page 1 of 2 |
| Author: | Jobs [ Thu Jan 11, 2007 7:57 pm ] |
| Post subject: | /save |
Well...I've never really done a tutorial before. So I figured I'd do something simple that I'm using, so, who knows someone else might find it useful too. Client Side: In modGameLogic under: Code: If LCase(Mid(MyText, 1, 5)) = "/help" Then Call AddText("Social Commands:", HelpColor) Call AddText("'msghere = Broadcast Message", HelpColor) Call AddText("-msghere = Emote Message", HelpColor) Call AddText("!namehere msghere = Player Message", HelpColor) Call AddText("/trade namehere = Player Trade, /accept to accept, /decline to decline", HelpColor) Call AddText("/party namehere = Invite player to party, /join to accept, /leave to decline", HelpColor) Call AddText("Available Commands: /help, /info, /who, /fps, /inv, /stats, /refresh, /declinechat, /chat, /8ball, /rainbow, /away, /calladmins, /wish, /minimap", HelpColor) MyText = "" Exit Sub End If Add this: Code: ' Save If LCase(Mid(MyText, 1, 5)) = "/save" Then Call SaveplayerData MyText = "" Exit Sub End If Then in ModClientTCP add this to the very bottom: Code: Sub SaveplayerData() Dim Packet As String Packet = "SAVEPLAYERDATA" & SEP_CHAR & END_CHAR Call SendData(Packet) End Sub Server Side: In ModServerTCP in the handle data sub, or ModHandledata, above this: Code: ' :: Request edit map packet :: Add: Code: ' ::::::::::::::::::::::::
' :: Save Player Packet :: ' :::::::::::::::::::::::: Case "saveplayerdata" If Map(GetPlayerMap(index)).Moral = MAP_MORAL_SAFE Then Call SavePlayer(index) Call PlayerMsg(index, "Character Stats & Inventory Saved", Yellow) Else Call PlayerMsg(index, "You must be in a town or house to save!", Yellow) End If Exit Sub That's all of it. It basically just makes it so when a player types /save in a safe zone map it saves their data...If there's any questions or something you don't understand feel free to ask. |
|
| Author: | Joost [ Thu Jan 11, 2007 8:14 pm ] |
| Post subject: | |
There's a typo in Save Player Packet |
|
| Author: | Jobs [ Thu Jan 11, 2007 8:28 pm ] |
| Post subject: | |
Ack, yeah sorry about that. I deleted some extra code I had there that isn't in any version of MS. I'll fix that. Thanks for pointing it out. |
|
| Author: | Da Undead [ Sat May 05, 2007 8:35 pm ] |
| Post subject: | |
On the server side, the paket should start with this.. Code: If LCase(Parse(0)) = "requesteditmap" Then
For MS, but if your using Elysium then you would use whats in the post |
|
| Author: | DarkC [ Sun Sep 14, 2008 7:28 pm ] |
| Post subject: | Re: /save |
I hope this is alright...Sense I like this tutorial, and it's useful for lots of people, I want to update it for the MS4 version. I already have tested it out and everything. And yes, I know it's simple to change and make it work for MS4. Anyway... ::Client Side:: First add this in modGameLogic under the Commands section. Code: ' Save If LCase(Mid(frmMirage.txtMyChat, 1, 5)) = "/save" Then Call SaveplayerData frmMirage.txtMyChat = "" Exit Sub End If Then in ModClientTCP add this at the bottom. Code: Sub SaveplayerData() Dim Packet As String Packet = CSaveplayerData & END_CHAR Call SendData(Packet) End Sub Then in modEnumerations add this under "Public Enum ClientPackets" Code: CSaveplayerData ::Server Side:: Now in modHandleData above the "Request edit map packet" add this. Code: ' :::::::::::::::::::::::: ' :: Save Player Packet :: ' :::::::::::::::::::::::: Case CSaveplayerData If Map(GetPlayerMap(Index)).Moral = MAP_MORAL_SAFE Then Call SavePlayer(Index) Call PlayerMsg(Index, "Character Stats & Inventory Saved", Yellow) Else Call PlayerMsg(Index, "You must be in a town or house to save!", Yellow) End If Exit Sub Then in modEnumerations under "Public Enum ClientPackets" add this. Code: CSaveplayerData All done. |
|
| Author: | Nean [ Sun Sep 14, 2008 9:01 pm ] |
| Post subject: | Re: /save |
MS4 saves all chars, like every thirty seconds dude. |
|
| Author: | DarkC [ Sun Sep 14, 2008 9:03 pm ] |
| Post subject: | Re: /save |
Oh, really? I just downloaded it today and have been using it a little, so I didn't really notice. |
|
| Author: | Mattyw [ Sun Sep 14, 2008 9:07 pm ] |
| Post subject: | Re: /save |
THIRTY SECONDS?! Code: ' Checks to save players every 10 minutes - Can be tweaked If Tick > LastUpdateSavePlayers Then UpdateSavePlayers LastUpdateSavePlayers = GetTickCount + 60000 End If Private Sub UpdateSavePlayers() Dim i As Long Code: Private Sub UpdateSavePlayers() Dim i As Long 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 End Sub modServerLoop.bas I removed the GlobalMsg. =-p |
|
| Author: | Nean [ Mon Sep 15, 2008 1:03 am ] |
| Post subject: | Re: /save |
Mattyw wrote: THIRTY SECONDS?! Code: ' Checks to save players every 10 minutes - Can be tweaked If Tick > LastUpdateSavePlayers Then UpdateSavePlayers LastUpdateSavePlayers = GetTickCount + 60000 End If Private Sub UpdateSavePlayers() Dim i As Long Code: Private Sub UpdateSavePlayers() Dim i As Long 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 End Sub modServerLoop.bas I removed the GlobalMsg. =-p I swear, I see that message "Saving all chars" like every thirty seconds. |
|
| Author: | Jacob [ Mon Sep 15, 2008 1:31 am ] |
| Post subject: | Re: /save |
That 60000 would be once a minute, not ten minutes. I don't know if i originally put in the wrong number or someone else changed it. |
|
| Author: | DarkC [ Mon Sep 15, 2008 1:50 am ] |
| Post subject: | Re: /save |
Dugor wrote: That 60000 would be once a minute, not ten minutes. I don't know if i originally put in the wrong number or someone else changed it. I didn't change that, that's how it was set when I got it. |
|
| Author: | Robin [ Mon Sep 15, 2008 1:59 am ] |
| Post subject: | Re: /save |
DarkC wrote: Dugor wrote: That 60000 would be once a minute, not ten minutes. I don't know if i originally put in the wrong number or someone else changed it. I didn't change that, that's how it was set when I got it. He meant another Mirage programmer. |
|
| Author: | Robin [ Mon Sep 15, 2008 11:53 am ] |
| Post subject: | Re: /save |
I think GIAKEN told me how he used to do that. Hell, you don't even need /save. Just have the other person log out then crash, as it saves on log out. |
|
| Author: | DarkC [ Mon Sep 15, 2008 12:53 pm ] |
| Post subject: | Re: /save |
Then what would be the safest thing to do about saves? Have the server save every 1second or even faster? Though, I can't help but think that'll help lag up the game badly. |
|
| Author: | Lea [ Mon Sep 15, 2008 1:02 pm ] |
| Post subject: | Re: /save |
Ideally it would load you when you sign on And save you when you sign off The server shouldn't crash, so there's no reason to save in between those times.... right? |
|
| Author: | Asrrin29 [ Tue Sep 16, 2008 4:22 am ] |
| Post subject: | Re: /save |
if you want your game to save as little as possible and still be secure in not losing data, you have to really complicate the code. It would be possible to put in error trapping code that initiates a save of all non-corrupted data before terminating the server. as far as power failures get a UPC that can connect to your computer via USB and somehow program the server to get the state of the UPC, so that when it is on battery the server knows to initiate a full save before closing. then the only times you would ever have to save is when the client is disconnected from the server. |
|
| Author: | Robin [ Tue Sep 16, 2008 9:48 am ] |
| Post subject: | Re: /save |
Tbh, the biggest threat is user-generated crashes. Just use CodeSMART to set up some error handling code (Make sure you're able to turn it on/off via a variable, otherwise your debugging days are over) and steal all GIAKEN's shit from Asphodel. I couldn't do most of the popular hacks on that, except use the client-side map report to warp between maps. Which he fixed. |
|
| Author: | Asrrin29 [ Tue Sep 16, 2008 1:17 pm ] |
| Post subject: | Re: /save |
that;s why I said to use error handling, at least server side. Any crash caused by a corrupted client would trigger error handling, and if you could program the handler to do an autosave of all other data except for the data causing the crash then you could potentially get around this. I don't know that exact procedure for all this code, and it might be too much of a headache to make it worthwhile, but I'm simply saying that it's possible to do. |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|